Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
Hi guys, I'm new here I hope if someone can help me with this.
I have 2 class :
_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")
_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.
Are you using the default purchase and stock modules? From your question, what you are looking for is a computed field.
From the documentation:
Fields can be computed (instead of read straight from the database) using the compute parameter. It must assign the computed value to the field. If it uses the values of other fields, it should specify those fields using depends():
from openerp import api
inv_qty = fields.Float(compute='_compute_inv_qty')
return product_id.??????(have to figure out what to return)
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 3/28/16, 11:17 AM|
|Seen: 686 times|
|Last updated: 3/29/16, 5:15 AM|