first push message
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
from . import controllers
|
||||
from . import models
|
||||
@@ -0,0 +1,34 @@
|
||||
{
|
||||
'name': "inherit_approval",
|
||||
|
||||
'summary': "Short (1 phrase/line) summary of the module's purpose",
|
||||
|
||||
'description': """
|
||||
Long description of module's purpose
|
||||
""",
|
||||
|
||||
'author': "My Company",
|
||||
'license': 'LGPL-3',
|
||||
'website': "https://www.yourcompany.com",
|
||||
|
||||
# Categories can be used to filter modules in modules listing
|
||||
# Check https://github.com/odoo/odoo/blob/15.0/odoo/addons/base/data/ir_module_category_data.xml
|
||||
# for the full list
|
||||
'category': 'Uncategorized',
|
||||
'version': '0.1',
|
||||
|
||||
# any module necessary for this one to work correctly
|
||||
'depends': ['xf_doc_approval','account','product'],
|
||||
|
||||
# always loaded
|
||||
'data': [
|
||||
'security/ir.model.access.csv',
|
||||
'views/views.xml',
|
||||
'views/templates.xml',
|
||||
],
|
||||
# only loaded in demonstration mode
|
||||
'demo': [
|
||||
'demo/demo.xml',
|
||||
],
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
from . import controllers
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,21 @@
|
||||
# from odoo import http
|
||||
|
||||
|
||||
# class InheritApproval(http.Controller):
|
||||
# @http.route('/inherit_approval/inherit_approval', auth='public')
|
||||
# def index(self, **kw):
|
||||
# return "Hello, world"
|
||||
|
||||
# @http.route('/inherit_approval/inherit_approval/objects', auth='public')
|
||||
# def list(self, **kw):
|
||||
# return http.request.render('inherit_approval.listing', {
|
||||
# 'root': '/inherit_approval/inherit_approval',
|
||||
# 'objects': http.request.env['inherit_approval.inherit_approval'].search([]),
|
||||
# })
|
||||
|
||||
# @http.route('/inherit_approval/inherit_approval/objects/<model("inherit_approval.inherit_approval"):obj>', auth='public')
|
||||
# def object(self, obj, **kw):
|
||||
# return http.request.render('inherit_approval.object', {
|
||||
# 'object': obj
|
||||
# })
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<odoo>
|
||||
<data>
|
||||
<!--
|
||||
<record id="object0" model="inherit_approval.inherit_approval">
|
||||
<field name="name">Object 0</field>
|
||||
<field name="value">0</field>
|
||||
</record>
|
||||
|
||||
<record id="object1" model="inherit_approval.inherit_approval">
|
||||
<field name="name">Object 1</field>
|
||||
<field name="value">10</field>
|
||||
</record>
|
||||
|
||||
<record id="object2" model="inherit_approval.inherit_approval">
|
||||
<field name="name">Object 2</field>
|
||||
<field name="value">20</field>
|
||||
</record>
|
||||
|
||||
<record id="object3" model="inherit_approval.inherit_approval">
|
||||
<field name="name">Object 3</field>
|
||||
<field name="value">30</field>
|
||||
</record>
|
||||
|
||||
<record id="object4" model="inherit_approval.inherit_approval">
|
||||
<field name="name">Object 4</field>
|
||||
<field name="value">40</field>
|
||||
</record>
|
||||
-->
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -0,0 +1 @@
|
||||
from . import models
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,133 @@
|
||||
from odoo import models, fields, api,_
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
class PaymentRequest(models.Model):
|
||||
_inherit = 'xf.doc.approval.document.package'
|
||||
_description = 'Payment Request'
|
||||
|
||||
# Additional Fields for Payment Request
|
||||
amount = fields.Float(string="Amount")
|
||||
partner_id = fields.Many2one('res.partner', string="Vendor")
|
||||
bill_id = fields.Many2one('account.move', string="Vendor Bill", readonly=True)
|
||||
payment_order_id = fields.Many2one('account.payment', string="Payment Order", readonly=True)
|
||||
payment_amount = fields.Monetary(
|
||||
string="Payment Amount",
|
||||
currency_field='currency_id', # Links to the currency field
|
||||
)
|
||||
currency_id = fields.Many2one(
|
||||
'res.currency',
|
||||
string="Currency",
|
||||
default=lambda self: self.env.company.currency_id, # Default to company currency
|
||||
readonly=True,
|
||||
)
|
||||
type_request = fields.Selection([('1','សំណើអនុម័តឯកសារ'),('2','សំណើសុំអនុម័តថវិកា'),('3','សំណើសុំអនុម័តគោលការណ៍ និងថវិកា')],string="Request type")
|
||||
|
||||
# Override action_finish_approval to include vendor bill creation
|
||||
def action_finish_approval(self):
|
||||
"""
|
||||
Finish the approval process and generate a vendor bill if approved.
|
||||
"""
|
||||
for record in self:
|
||||
if record.approval_state == 'approved':
|
||||
record.state = 'approved'
|
||||
# Generate the draft vendor bill
|
||||
record._generate_vendor_bill()
|
||||
else:
|
||||
raise UserError(_('Document Package must be fully approved!'))
|
||||
|
||||
def _generate_vendor_bill(self):
|
||||
"""
|
||||
Generate a draft vendor bill in Accounting.
|
||||
"""
|
||||
for record in self:
|
||||
if not record.partner_id and record.type_request != '2':
|
||||
raise UserError(_("No vendor selected for this payment request."))
|
||||
|
||||
# Dynamically fetch a product or create one if none exists
|
||||
product = self.env['product.product'].search([], limit=1)
|
||||
if not product:
|
||||
product = self.env['product.product'].create({
|
||||
'name': 'Default Service',
|
||||
'type': 'service',
|
||||
'list_price': record.payment_amount,
|
||||
})
|
||||
|
||||
# Create the draft vendor bill
|
||||
bill = self.env['account.move'].create({
|
||||
'move_type': 'in_invoice',
|
||||
'partner_id': record.partner_id.id,
|
||||
'invoice_date': fields.Date.today(),
|
||||
'invoice_line_ids': [(0, 0, {
|
||||
'product_id': product.id,
|
||||
'quantity': 1,
|
||||
'price_unit': record.payment_amount,
|
||||
'name': f"Payment Request - {record.name}",
|
||||
})],
|
||||
})
|
||||
record.write({'bill_id': bill.id})
|
||||
|
||||
def action_request_bank_payment(self):
|
||||
"""
|
||||
Request bank payment after vendor bill is created.
|
||||
"""
|
||||
for record in self:
|
||||
if not record.bill_id:
|
||||
raise UserError(_("No vendor bill exists for this payment request."))
|
||||
|
||||
# Create a payment order
|
||||
payment = self.env['account.payment'].create({
|
||||
'payment_type': 'outbound',
|
||||
'partner_id': record.partner_id.id,
|
||||
'amount': record.payment_amount,
|
||||
'date': fields.Date.today(),
|
||||
'journal_id': self.env['account.journal'].search([('type', '=', 'bank')], limit=1).id,
|
||||
'payment_method_id': self.env.ref('account.account_payment_method_manual_out').id,
|
||||
})
|
||||
record.write({'payment_order_id': payment.id})
|
||||
return {
|
||||
'type': 'ir.actions.client',
|
||||
'tag': 'display_notification',
|
||||
'params': {
|
||||
'title': 'Request Bank Payment',
|
||||
'message': f'you are request bank payment done.',
|
||||
'sticky': False,
|
||||
}
|
||||
}
|
||||
|
||||
def action_post_vendor_bill(self):
|
||||
"""
|
||||
Post the vendor bill in Accounting.
|
||||
"""
|
||||
for record in self:
|
||||
if not record.bill_id:
|
||||
raise UserError(_("No vendor bill exists for this payment request."))
|
||||
if record.bill_id.state != 'draft':
|
||||
raise UserError(_("The vendor bill is already posted or canceled."))
|
||||
|
||||
# Post the vendor bill
|
||||
record.bill_id.action_post()
|
||||
if record.bill_id:
|
||||
return {
|
||||
'type': 'ir.actions.client',
|
||||
'tag': 'display_notification',
|
||||
'params': {
|
||||
'title': 'Post Vendor Bill',
|
||||
'message': f'you are Post Vendor Bill done.',
|
||||
'sticky': False,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class ProposalPayment(models.Model):
|
||||
_name = 'p.payment'
|
||||
_description = 'សំណើសុំអនុម័តគោលការណ៍'
|
||||
|
||||
name = fields.Char()
|
||||
amount = fields.Monetary(string="Payment Amount",
|
||||
currency_field='currency_id')
|
||||
currency_id = fields.Many2one(
|
||||
'res.currency',
|
||||
string="Currency",
|
||||
default=lambda self: self.env.company.currency_id, # Default to company currency
|
||||
readonly=True,
|
||||
)
|
||||
@@ -0,0 +1,2 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_p_payment,Access model pay payment,model_p_payment,base.group_user,1,1,1,1
|
||||
|
@@ -0,0 +1,24 @@
|
||||
<odoo>
|
||||
<data>
|
||||
<!--
|
||||
<template id="listing">
|
||||
<ul>
|
||||
<li t-foreach="objects" t-as="object">
|
||||
<a t-attf-href="#{ root }/objects/#{ object.id }">
|
||||
<t t-esc="object.display_name"/>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
<template id="object">
|
||||
<h1><t t-esc="object.display_name"/></h1>
|
||||
<dl>
|
||||
<t t-foreach="object._fields" t-as="field">
|
||||
<dt><t t-esc="field"/></dt>
|
||||
<dd><t t-esc="object[field]"/></dd>
|
||||
</t>
|
||||
</dl>
|
||||
</template>
|
||||
-->
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="view_request_approval_form_inherit" model="ir.ui.view">
|
||||
<field name="name">Request Approval</field>
|
||||
<field name="model">xf.doc.approval.document.package</field>
|
||||
<field name="inherit_id" ref="xf_doc_approval.xf_doc_approval_document_package_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//header" position="inside">
|
||||
<button string="Request Bank Payment" type="object" name="action_request_bank_payment"
|
||||
invisible="state != 'approved' or payment_order_id != False" class="btn-primary" groups="account.group_account_user,account.group_account_manager"/>
|
||||
<button string="Post Vendor Bill" type="object" name="action_post_vendor_bill"
|
||||
invisible="1" class="btn-primary" groups="account.group_account_user,account.group_account_manager"/>
|
||||
</xpath>
|
||||
<xpath expr="//group[@name='documents']" position="before">
|
||||
<div>
|
||||
<b><label for="type_request" string="Type of Request"/></b>
|
||||
<field name="type_request" required="1"/>
|
||||
</div>
|
||||
</xpath>
|
||||
<xpath expr="//group[@name='documents']" position="after">
|
||||
<group string="Payment Details" invisible="type_request == '1'">
|
||||
<field name="payment_amount"/>
|
||||
<field name="currency_id" readonly="1"/>
|
||||
<field name="partner_id" required="type_request == '2'"/>
|
||||
<field name="bill_id" readonly="1"/>
|
||||
<field name="payment_order_id" readonly="1"/>
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user