from email.policy import default
from attr import fields from odoo
import models, fields, api
classFashionInvoice(models.Model):
_name = 'fashion.invoice'
_rec_name = 'invoice_name'
invoice_name = fields.Char("Invoice Name", default="INVOICE-NAME-")
invoice_code = fields.Char("Invoice Code", default="INVOICE-ID")
invoice_customer = fields.Char("Customer", default="INVOICE-ID")
totalinvoice_price = fields.Float("Total Invoice Price")
invoice_lines = fields.One2many('fashion.invoice.line','invoice_id', string="Invoice Line")
state = fields.Selection([ ('ordered', 'Ordered'), ('paid', 'Paid') ], default='ordered', string="Status", required=True)
defaction_delete(self):
self.unlink()
view_invoices = self.env.ref('foodstore.action_invoice_order').read()[0]
view_invoices['target'] = 'main'
return view_invoices
defaction_submit_paid(self):
self.state = 'paid'
view_paid = self.env.ref('foodstore.action_invoice_paid').read()[0]
view_paid['domain'] = [('state', '=', 'paid')]
view_paid['target'] = 'main'
returnview_paid
classInvoiceLine(models.Model):
_name = 'fashion.invoice.line'
product_id = fields.Many2one('fashion.product', string="Product Name")
product_qty = fields.Integer(string = "Quantity", default="1")
invoice_id = fields.Many2one('fashion.invoice', string="Invoice ID")
order_code = fields.Char("Order Code", default="ORDER-")
price_id = fields.Float(related='product_id.price', string="Price")
sale_price = fields.Float(related='price_id', string="Sale Price", readonly=False)
total_price = fields.Float("Total Price", store=True, compute="action_calculate_price")
@api.depends('sale_price','product_qty')
defaction_calculate_price(self):
for data in self:
total_prices = data.total_price
total_prices = data.sale_price * data.product_qty
data.total_price = total_prices
Here above is my code, basically, i want to change a record(state) using one button(action_submit_paid), and its solve actually, but the record from the other models which is fashion.order that has similar state still there, i want to change the state too, to make it hide from menu ordered in model order. any idea how to do it?