Skip to Content
Menu
This question has been flagged
2 Replies
3256 Zobrazenia

Hi all,

I'd like to add vendor/client in product moves line so I can see who sold product or who bought it. Also, I'd like to show cost/price to see how much it costed or how much I got for product. Here is visual representation of it 


I know how to inherit view from xml, just don't know how to call this fields (show information) - appreciate any help.

Avatar
Zrušiť

Hi,

This is for the which version?

Autor

Sorry I didn't mention it, v15

Best Answer

Hello Matija,

To get the fields on stock.move.line you need to inherit the model and refer to the below code as well as add the fields on the xml file.
Explanation of the code:
I’ve taken the value of partner(vendor/customer) from its related move_id.partner_id
Where cost_price is a computed field which will be called based on dependencies you add , taking the value from move_id’s particular sale_line_id’s price.

Please find code in comment. 

I Hope this will help you. 

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

Avatar
Zrušiť

class StockMoveLine(models.Model):
_inherit = "stock.move.line"

partner_name = fields.Many2one('res.partner',string="Partner Name",related="move_id.partner_id")
cost_price = fields.Monetary(compute="compute_cost_price",string="Cost Price",
currency_field="currency_id")
currency_id = fields.Many2one("res.currency",
string="Currency",related='company_id.currency_id',required=True)

@api.depends('qty_done', 'product_uom_id', 'product_id', 'move_id')
def compute_cost_price(self):
for rec in self:
rec.cost_price = 0
rec .cost_price = rec.move_id.sale_line_id.price_subtotal

Autor

This works, thank you so much Jainesh!

Best Answer

Hi,

The field picking_partner_id already in move lines,
for the location you just need to do, picking_partner_id field visible. and for the cost/price you need to do development where you can display the cost from the lines.

Thanks,


Avatar
Zrušiť
Related Posts Replies Zobrazenia Aktivita
2
sep 21
3882
2
mar 15
4044
1
nov 24
4137
1
aug 23
1712
2
jan 22
11513