class BillAdjustment(models.Model):
_name = 'bill.adjustment'
_description = 'Bill And Adjustment'
products = fields.One2many('bill.adjustment.items', 'bill_id', string='Products')
class BillAdjustmentItems(models.Model):
_name = 'bill.adjustment.items'
_description = 'Job Summary Items'
bill_id = fields.Many2one('bill.adjustment', string='Bill Summary')
item_name = fields.Char('Item Name')
quantity = fields.Float('Quantity')
unit_price = fields.Float('Unit Price')
total = fields.Float('Total', compute='_compute_total', store=True)
bill_id = fields.Many2one('bill.adjustment', string='Bill Adjustment')
class AccountAmount(models.Model):
_inherit = "account.move"
type_id = fields.Many2one(
string="Type", comodel_name="bill.adjustment", required=True)
approve_amount = fields.Float(string="Approve Amount")
@api.onchange('type_id')
def onchange_type_id(self):
if self.type_id:
bill_adjustment = self.env['bill.adjustment'].browse(self.type_id.id)
self.approve_amount = bill_adjustment.app_amount if bill_adjustment else 0.0
def create_move_lines(self):
for record in self:
if record.type_id:
bill_adjustment = self.env['bill.adjustment'].browse(record.type_id.id)
for item in bill_adjustment.products:
product_id = item.item_name # Assuming item_name is a Many2one field
quantity = item.quantity
price_unit = item.unit_price
price_subtotal = item.total
# Create account move line using item data
self.env['account.move.line'].create({
'move_id': record.id,
'product_id': product_id,
'quantity': quantity,
'price_unit': price_unit,
'price_subtotal': price_subtotal
})
here i want when i click on create_move_lines then automatically with the type i mention this type_id bill.adjustment/items filed value will fetch in accout.move.line model
in product_id ,quantity,price_unit,price_subtotal field
but here i face this erro
sycopg2.errors.InvalidTextRepresentation: invalid input syntax for type integer: "cold drinks"
LINE 1: ...000000', NULL, 44, '1800.00', '1800.00', '20.00', 'cold drin...
how i solve this?
please help me