diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2023-07-17 13:35:08 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2023-07-17 13:35:08 +0700 |
| commit | bb8d8fe7824dc929634bf00f2dcc7d51630257d3 (patch) | |
| tree | 3d9d3abdee07822270820ecda0e631f41eafcd4a | |
| parent | 855f63e1c39ba1ff4d84360845949bc260462c83 (diff) | |
add new field to receipt bill
| -rw-r--r-- | indoteknik_custom/models/bill_receipt.py | 34 | ||||
| -rw-r--r-- | indoteknik_custom/views/bill_receipt.xml | 30 | ||||
| -rwxr-xr-x | indoteknik_custom/views/purchase_order.xml | 1 |
3 files changed, 55 insertions, 10 deletions
diff --git a/indoteknik_custom/models/bill_receipt.py b/indoteknik_custom/models/bill_receipt.py index 31c09b33..806edc25 100644 --- a/indoteknik_custom/models/bill_receipt.py +++ b/indoteknik_custom/models/bill_receipt.py @@ -16,6 +16,15 @@ class BillReceipt(models.Model): description = fields.Text(string='Description') validated = fields.Boolean(string="Validated", readonly=True) bill_line = fields.One2many('bill.receipt.line', 'bill_id', string='Bill Receipt Lines') + grand_total = fields.Float(string="Grand Total") + + def compute_amt_total_without_service(self): + for order in self: + sum_price_total = 0 + for line in order.order_line: + if line.product_id.type == 'product': + sum_price_total += line.price_total + order.amount_total_without_service = sum_price_total @api.model def create(self, vals): @@ -48,8 +57,33 @@ class BillReceiptLine(models.Model): sale_order_id = fields.Many2one('sale.order', string='Sale Order') user_id = fields.Many2one('res.users', string='Purchase Rep') payment_term_id = fields.Many2one('account.payment.term', string='Payment Terms') + vendor_id = fields.Many2one('res.partner', string='Vendor') + date_approve = fields.Datetime(string='Confirmation Date') + date_planned = fields.Datetime(string='Receipt Date') + amount_untaxed = fields.Float(string='Untaxed Amount') amount_total = fields.Float(string='Total') reference = fields.Char(string='Reference') + partner_ref = fields.Char(string='Vendor Reference') + + @api.onchange('po_id') + def onchange_partner_ref(self): + self.partner_ref = self.po_id.partner_ref + + @api.onchange('po_id') + def onchange_vendor_id(self): + self.vendor_id = self.po_id.partner_id + + @api.onchange('po_id') + def onchange_date_approve(self): + self.date_approve = self.po_id.date_approve + + @api.onchange('po_id') + def onchange_date_planned(self): + self.date_planned = self.po_id.date_planned + + @api.onchange('po_id') + def onchange_amount_untaxed(self): + self.amount_untaxed = self.po_id.amount_untaxed @api.onchange('po_id') def onchange_user_id(self): diff --git a/indoteknik_custom/views/bill_receipt.xml b/indoteknik_custom/views/bill_receipt.xml index 6e27ee12..cfc268b0 100644 --- a/indoteknik_custom/views/bill_receipt.xml +++ b/indoteknik_custom/views/bill_receipt.xml @@ -14,6 +14,25 @@ </field> </record> + <record id="bill_receipt_line_tree" model="ir.ui.view"> + <field name="name">bill.receipt.line.tree</field> + <field name="model">bill.receipt.line</field> + <field name="arch" type="xml"> + <tree> + <field name="partner_ref"/> + <field name="po_id"/> + <field name="sale_order_id"/> + <field name="user_id"/> + <field name="vendor_id"/> + <field name="date_approve"/> + <field name="date_planned"/> + <field name="reference"/> + <field name="amount_untaxed"/> + <field name="amount_total"/> + </tree> + </field> + </record> + <record id="bill_receipt_form" model="ir.ui.view"> <field name="name">bill.receipt.form</field> <field name="model">bill.receipt</field> @@ -42,16 +61,7 @@ </group> <notebook> <page string="Bill Line" name="bill_line"> - <field name="bill_line" attrs="{'readonly': [('validated', '=', True)]}"> - <tree editable="bottom"> - <field name="po_id"/> - <field name="sale_order_id"/> - <field name="user_id"/> - <field name="payment_term_id"/> - <field name="amount_total"/> - <field name="reference"/> - </tree> - </field> + <field name="bill_line" attrs="{'readonly': [('validated', '=', True)]}"/> </page> </notebook> </sheet> diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index 4efa8cf4..2f8590f3 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -32,6 +32,7 @@ <field name="date_order" position="before"> <field name="sale_order_id" attrs="{'readonly': [('state', 'not in', ['draft'])]}"/> <field name="approval_status"/> + <field name="amount_total_without_service"/> </field> <field name="currency_id" position="after"> <field name="summary_qty_po"/> |
