Hello Clive,welcome to the struggle ;) I have been trying to do it for a year now. I know for a fact that odoo can handle that with a custom development, I have seen it working well on some odoo´s partners.I somehow manage to do something aprox but not perfect.
I can tell you what I have done:
1º First add a custom fueld to your serial numbers items called "lot.x_serial_purchase_precio" , and "price_unit" is the sales price.
- the formula for x_serial_purchase_precio ( in model = lot/serial numbers )
for record in self: record['x_serial_purchase_precio'] = 0
if record.purchase_order_ids:
xids = [x for x in record.purchase_order_ids.ids]
purchases = self.env['purchase.order'].search([('id','in',xids)],order='date_order desc', limit=1)
move_line = self.env['stock.move.line'].search([('move_id.purchase_line_id.order_id','in',xids),('product_id','=',record.product_id.id),('lot_id','=',record.id)], limit=1)
if move_line: xproduct = record.product_id.id xorder = purchases.id line_obj = move_line.move_id.purchase_line_id #lines_obj = self.env['purchase.order.line'].search([('order_id','=',xorder),('product_id','=',xproduct),('state','in',['purchase'])],order='price_unit', limit=1)
if line_obj: record['x_serial_purchase_precio'] = line_obj.price_unit
2º Create three taxes for rebu ( one for the base 1, base 2 and tax ). These three taxes are phyton calculated as follows:
- base 1:
if lot.x_serial_purchase_precio > price_unit: result = 0else: result = quantity * (price_unit - lot.x_serial_purchase_precio) / 1.21
- base 2:
if lot.x_serial_purchase_precio > price_unit: result = quantity*price_unitelse: result = quantity*lot.x_serial_purchase_precio
- tax:
if lot.x_serial_purchase_precio > price_unit: result = 0 else: result = quantity * ((price_unit - lot.x_serial_purchase_precio) / 1.21) * 0.21
Then each time you sell some item in REBU you have to add these three taxes to the item. It is not complicated once you have understood it. Hire an specialist but this is how I have managed to do it for now ( though I hired other guy to simplify things ).
I have other automatical process, such as: if you buy and item in REBU then that item is flagged with "rebu=true", then it is allowed/forced to be sold in REBU ( adding the three taxes autmaticly ). But still, a mess.
I hope it helps