I am doing simple custom inventory module. In that, my product and purchase fields i listed below.
product table
_name = "ims.product"
_description = "Product Module"
_columns = {
'name': fields.char('Product Name', required=True),
'cost': fields.float('Product Cost',digits=(12,2), required=True),
'stock': fields.integer('Stock'),
'category': fields.many2one('ims.category', 'Category', required=True),
}
Purchase table
_columns = {
'supplier': fields.many2one('ims.supplier', 'Supplier', required=True),
'address': fields.char('Address'),
'phone': fields.char('Phone'),
'email': fields.char('Email'),
'product': fields.one2many('ims.purchase.list','purchase_id','Items', required=True),
'grand_total': fields.function(_amount_all_wrapper, digits_compute=dp.get_precision('Account'), string='Grand Total',
store={
'ims.purchase': (lambda self, cr, uid, ids, c={}: ids, ['product'], 10),
'ims.purchase.list': (_get_order, ['price_unit'], 10),
},
multi='sums', help="The total amount."),
while purchase i have to update the stock(Old+new stock) from the purchase.
I am new to odoo. If anything is very basic, am sorry to that.
Thanks for your helps.