Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
3233 Widoki

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.

Awatar
Odrzuć

Hi,

This is for the which version?

Autor

Sorry I didn't mention it, v15

Najlepsza odpowiedź

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

Awatar
Odrzuć

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!

Najlepsza odpowiedź

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,


Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
wrz 21
3873
2
mar 15
4036
1
lis 24
4123
1
sie 23
1707
2
sty 22
11491