I have created new page named 'service' in account move line and added some fields in to it.Now i want to auto fill the next page('invoice lines')fields when changing corresponding fields in the 'service' page. anyone could you please help me
here is my .py code
from odoo import models, fields, api, _
class XnProjectService(models.Model):
_inherit = 'account.move'
nx_service_line_ids = fields.One2many('nx_service_line', 'nx_account_move_id',
string="service Lines",
readonly=True,
states={'draft': [('readonly', False)]}, copy=True)
class NxProjectServiceLine(models.Model):
_name = 'nx_service_line'
_description = "Nx Service Line"
nx_account_move_id = fields.Many2one('account.move', string="Account ID")
nx_product = fields.Many2one('product.product', string='Product', required='1')
nx_commission = fields.Float(string="Commission")
nx_label = fields.Char(string='Label')
nx_quantity = fields.Float(string="Quantity", default='1.0')
nx_gvnmt_fee = fields.Float(string="Government Fee")
nx_rate = fields.Float(string="Rate")
nx_amount = fields.Float(string="Amount")
nx_3rd_party_amount = fields.Float(string="Third Party Amount")
xn_tax_id = fields.Many2one('account.tax', string="Vat")
@api.depends('nx_quantity', 'nx_rate')
def nx_compute_amount(self):
for record in self:
record.nx_amount = record.nx_quantity * record.nx_rate
record.nx_gvnmt_fee = record.nx_quantity * record.nx_product.nx_government_fee_amount
record.nx_3rd_party_amount = record.nx_quantity * record.nx_product.nx_third_party_amount
record.nx_commission = record.nx_quantity * record.nx_product.nx_commission_amount
@api.onchange('nx_product')
def _get_label(self):
self.nx_label = self.nx_product.name
self.nx_rate = self.nx_product.list_price
self.nx_gvnmt_fee = self.nx_product.nx_government_fee_amount
self.nx_3rd_party_amount = self.nx_product.nx_third_party_amount
self.nx_commission = self.nx_product.nx_commission_amount
`