Skip to Content
Menu
This question has been flagged
2 Replies
2187 Views

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
Discard

Hi,

This is for the which version?

Author

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
Discard

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

Author

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
Discard
Related Posts Replies Views Activity
2
Sep 21
2575
2
Mar 15
3121
1
Nov 24
3106
1
Aug 23
815
2
Jan 22
9841