Hi guys, I'm new here I hope if someone can help me with this.
I have 2 class :
class Purchase(models.Model):
_name = 'tjara.purchase'
name = fields.Char(string="Nom Achat", required=True)
....
device = fields.Many2one('tjara.stock', ondelete='cascade', string="Device")
number_product = fields.Integer(string="Number of product")
And :
class Stock(models.Model):
_name = 'tjara.stock'
name = fields.Char(string="Device Name", required=True)
number = fields.Integer(string="Number in stock")
How can I check if there are products in the stock for the current purchase ? (stock.number need to be > than purchase.number_product.)
And how can I decrement the number in stock automatically after every purchase ? (stock.number = stock.number - purchase.number_product)
Thanks a lot.