mrp_average_cost: Fix decimal precision

product_usability: add link to show history of standard price
This commit is contained in:
Alexis de Lattre
2017-05-22 20:57:33 +02:00
committed by Raphaël Valyi
parent fc29b2b480
commit ae9a73488e
2 changed files with 35 additions and 9 deletions

View File

@@ -16,6 +16,17 @@ class ProductTemplate(models.Model):
purchase_ok = fields.Boolean(track_visibility='onchange') purchase_ok = fields.Boolean(track_visibility='onchange')
active = fields.Boolean(track_visibility='onchange') active = fields.Boolean(track_visibility='onchange')
def show_product_price_history(self):
self.ensure_one()
products = self.env['product.product'].search(
[('product_tmpl_id', '=', self._context['active_id'])])
action = self.env['ir.actions.act_window'].for_xml_id(
'product_usability', 'product_price_history_action')
action.update({
'domain': "[('id', 'in', %s)]" % products.ids,
})
return action
class ProductProduct(models.Model): class ProductProduct(models.Model):
_inherit = 'product.product' _inherit = 'product.product'
@@ -38,9 +49,26 @@ class ProductProduct(models.Model):
'unique(default_code)', 'unique(default_code)',
'This internal reference already exists!')] 'This internal reference already exists!')]
def show_product_price_history(self):
self.ensure_one()
action = self.env['ir.actions.act_window'].for_xml_id(
'product_usability', 'product_price_history_action')
action.update({
'domain': "[('product_id', '=', %d)]" % self.ids[0],
})
return action
class ProductSupplierinfo(models.Model): class ProductSupplierinfo(models.Model):
_inherit = 'product.supplierinfo' _inherit = 'product.supplierinfo'
name = fields.Many2one( name = fields.Many2one(
domain=[('supplier', '=', True), ('parent_id', '=', False)]) domain=[('supplier', '=', True), ('parent_id', '=', False)])
class ProductPriceHistory(models.Model):
_inherit = 'product.price.history'
company_currency_id = fields.Many2one(
related='company_id.currency_id', readonly=True,
string='Company Currency')

View File

@@ -16,8 +16,9 @@
<group name="main"> <group name="main">
<field name="product_id" invisible="not context.get('product_price_history_main_view')"/> <field name="product_id" invisible="not context.get('product_price_history_main_view')"/>
<field name="datetime"/> <field name="datetime"/>
<field name="cost"/> <field name="cost" widget="monetary" options="{'currency_field': 'company_currency_id'}"/>
<field name="company_id" groups="base.group_multi_company"/> <field name="company_id" groups="base.group_multi_company"/>
<field name="company_currency_id" invisible="1"/>
</group> </group>
</form> </form>
</field> </field>
@@ -30,8 +31,9 @@
<tree string="Product Price History" editable="bottom"> <tree string="Product Price History" editable="bottom">
<field name="product_id" invisible="not context.get('product_price_history_main_view')"/> <field name="product_id" invisible="not context.get('product_price_history_main_view')"/>
<field name="datetime"/> <field name="datetime"/>
<field name="cost"/> <field name="cost" widget="monetary" options="{'currency_field': 'company_currency_id'}"/>
<field name="company_id" groups="base.group_multi_company"/> <field name="company_id" groups="base.group_multi_company"/>
<field name="company_currency_id" invisible="1"/>
</tree> </tree>
</field> </field>
</record> </record>
@@ -67,13 +69,9 @@
<field name="model">product.template</field> <field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view" /> <field name="inherit_id" ref="product.product_template_form_view" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<!-- <field name="standard_price" class="oe_inline" position="after">
<group name="general" position="after"> <button name="show_product_price_history" class="oe_inline oe_link" type="object" string="Show History" context="{'active_id': active_id}"/>
<group name="price_history" string="Price History"> </field>
<field name="price_history_ids" nolabel="1"/>
</group>
</group>
-->
<!-- START for wider 'name' field --> <!-- START for wider 'name' field -->
<!-- Don't make it too big, othesize computers with small resolutions <!-- Don't make it too big, othesize computers with small resolutions
will see the product name + image under the block of buttons --> will see the product name + image under the block of buttons -->