[Openerp-community] Update a field in model product.template when PO is confirmed

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Openerp-community] Update a field in model product.template when PO is confirmed

José Persichini

Update a field in model product.template when PO is confirmed

Hello, I have Odoo 8 running over Win 7 x64.

I am developing a new module, I have created a class that inherit from product.template:

from openerp import fields, models

class Product(models.Model):
    _inherit = 'product.template'

    last_cost_price = fields.Float(digits=(8,2), string="Last cost price", readonly=True)

When the user confirms a PO, I want to read every line order and set the unit_price of this order_line in last_cost_price of the corresponding product.template.

Have I to override wkf_confirm_order() method of purchase_order class? In this case, how can I access to product.last_cost_price attribute to edit it?

Thanks!


_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Openerp-community] Update a field in model product.template when PO is confirmed

Mohamed M. Hagag

Hi José,


I believe this function already exists in v.8 .


Use the real price costing method .


to activate it go to Purchase settings and activate the option contains real and average price then apply.



test it by creating POs for the one product and every new PO increase or decrease the price and check the product cost price after each PO confirmation.


Regards,




On 12/01/2014 11:24 PM, José Persichini wrote:

Update a field in model product.template when PO is confirmed

Hello, I have Odoo 8 running over Win 7 x64.

I am developing a new module, I have created a class that inherit from product.template:

from openerp import fields, models

class Product(models.Model):
    _inherit = 'product.template'

    last_cost_price = fields.Float(digits=(8,2), string="Last cost price", readonly=True)

When the user confirms a PO, I want to read every line order and set the unit_price of this order_line in last_cost_price of the corresponding product.template.

Have I to override wkf_confirm_order() method of purchase_order class? In this case, how can I access to product.last_cost_price attribute to edit it?

Thanks!



_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp


_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Openerp-community] Update a field in model product.template when PO is confirmed

José Persichini
Hi Mohamed, thanks for your reply.

This method is not a solution for me.

For example:
-We have a product A.
1. We confirm a PO with unit price of $10 for 1 product A.
2. We confirm a PO with unit price of $20 for 1 product A.

With the real price method, the cost price is $15. But in the method I need, the cost price is $20 (the last unit price confirmed).

How can I do this?

Thanks!

El 01/12/2014 06:30 p.m., Mohamed M. Hagag escribió:

Hi José,


I believe this function already exists in v.8 .


Use the real price costing method .


to activate it go to Purchase settings and activate the option contains real and average price then apply.



test it by creating POs for the one product and every new PO increase or decrease the price and check the product cost price after each PO confirmation.


Regards,




On 12/01/2014 11:24 PM, José Persichini wrote:

Update a field in model product.template when PO is confirmed

Hello, I have Odoo 8 running over Win 7 x64.

I am developing a new module, I have created a class that inherit from product.template:

from openerp import fields, models

class Product(models.Model):
    _inherit = 'product.template'

    last_cost_price = fields.Float(digits=(8,2), string="Last cost price", readonly=True)

When the user confirms a PO, I want to read every line order and set the unit_price of this order_line in last_cost_price of the corresponding product.template.

Have I to override wkf_confirm_order() method of purchase_order class? In this case, how can I access to product.last_cost_price attribute to edit it?

Thanks!



_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp



_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp


_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Openerp-community] Update a field in model product.template when PO is confirmed

Lionel Sausin
Hi,

I'm developing a version of this feature which plugs into the OCA margin-analysis addons here :
https://github.com/OCA/margin-analysis/pull/12
Please join in there and comment my proposal, don't redevelop it.

Alternatively, OdooMRP has another implementation incubating in https://github.com/odoomrp/odoomrp-wip/ (module product_last_price_info).

Lionel Sausin.

_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Openerp-community] Update a field in model product.template when PO is confirmed

José Persichini
Hi, thanks for your reply. I have solved my question.

I override wkf_confirm_order() method and here I do the actions...

Bye

El 02/12/2014 02:42 p.m., Lionel Sausin escribió:
Hi,

I'm developing a version of this feature which plugs into the OCA margin-analysis addons here :
https://github.com/OCA/margin-analysis/pull/12
Please join in there and comment my proposal, don't redevelop it.

Alternatively, OdooMRP has another implementation incubating in https://github.com/odoomrp/odoomrp-wip/ (module product_last_price_info).

Lionel Sausin.


_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp


_______________________________________________
Mailing list: https://launchpad.net/~openerp-community
Post to     : [hidden email]
Unsubscribe : https://launchpad.net/~openerp-community
More help   : https://help.launchpad.net/ListHelp
Loading...