Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
2 Antworten
3282 Ansichten

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
Verwerfen

Hi,

This is for the which version?

Autor

Sorry I didn't mention it, v15

Beste Antwort

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
Verwerfen

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!

Beste Antwort

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
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
2
Sept. 21
3908
2
März 15
4064
1
Nov. 24
4158
1
Aug. 23
1733
2
Jan. 22
11542