[FIX] various: enforce currency presence for monetary widgets

When a field is specified as widget="monetary" it makes sense to have the
currency actually shows. It won't happen if currency field is not present
within the view.

An heuristic to detect missing currency field presence when using monetary
fields or monetary widget tag will land soon in master. As this commit targets
a stable version only view fixes are provided.

Task ID-2329114
PR #56946

X-original-commit: 9c1c848ad1e8fef11320e2a162b008de7e304bcb
This commit is contained in:
Victor Feyens
2020-09-03 08:45:22 +00:00
committed by Thibault Delavallée
parent f9f2c561bd
commit 40fb37b943
8 changed files with 21 additions and 0 deletions
+1
View File
@@ -105,6 +105,7 @@
context="{'default_partner_id': active_id}">
<div class="o_form_field o_stat_info">
<span class="o_stat_value">
<field name="currency_id" invisible="1"/>
<field name="total_invoiced" widget='monetary' options="{'currency_field': 'currency_id'}"/>
</span>
<span class="o_stat_text">Invoiced</span>
@@ -104,6 +104,7 @@
<field name="description"/>
<field name="product_id" invisible="1"/>
<field name="price" widget="monetary"/>
<field name="currency_id" invisible="1"/>
</tree>
</field>
</record>
+1
View File
@@ -279,6 +279,7 @@
<div class="col-6">
<span class="float-right">
<field name="amount" widget="monetary"/>
<field name="currency_id" invisible="1"/>
</span>
</div>
</div>
@@ -55,6 +55,7 @@
<field name="tax_ids" widget="many2many_tags" invisible="1"/>
<field name="price_subtotal" widget="monetary" force_save="1"/>
<field name="price_subtotal_incl" widget="monetary" force_save="1"/>
<field name="currency_id" invisible="1"/>
</tree>
<form string="Order lines">
<group col="4">
@@ -68,6 +69,7 @@
<field name="tax_ids" widget="many2many_tags" invisible="1"/>
<field name="pack_lot_ids" widget="many2many_tags" groups="stock.group_production_lot"/>
<field name="notice"/>
<field name="currency_id" invisible="1"/>
</group>
</form>
</field>
@@ -90,6 +92,7 @@
class="oe_subtotal_footer_separator"
widget="monetary"
attrs="{'invisible': [('amount_paid','=', 'amount_total')]}"/>
<field name="currency_id" invisible="1"/>
</group>
<div class="oe_clear"/>
</page>
@@ -274,6 +277,7 @@
<field name="price_subtotal" readonly="1" sum="Sum of subtotals" widget="monetary"/>
<field name="price_subtotal_incl" readonly="1" sum="Sum of subtotals" widget="monetary"/>
<field name="create_date" readonly="1"/>
<field name="currency_id" invisible="1"/>
</tree>
</field>
</record>
@@ -289,6 +293,7 @@
<field name="discount" widget="monetary"/>
<field name="price_unit" widget="monetary"/>
<field name="create_date" />
<field name="currency_id"/>
</group>
</form>
</field>
@@ -329,6 +334,7 @@
<field name="product_id" />
<field name="qty" />
<field name="price_unit" widget="monetary"/>
<field name="currency_id" invisible="1"/>
</tree>
</field>
</record>
+1
View File
@@ -674,6 +674,7 @@
<field name="product_qty"/>
<field name="product_uom" groups="uom.group_uom"/>
<field name="price_subtotal" widget="monetary"/>
<field name="currency_id" invisible="1"/>
<field name="date_planned" widget="date"/>
</tree>
</field>
+5
View File
@@ -79,6 +79,7 @@ class Repair(models.Model):
'product.pricelist', 'Pricelist',
default=lambda self: self.env['product.pricelist'].search([('company_id', 'in', [self.env.company.id, False])], limit=1).id,
help='Pricelist of the selected partner.', check_company=True)
currency_id = fields.Many2one(related='pricelist_id.currency_id')
partner_invoice_id = fields.Many2one('res.partner', 'Invoicing Address', check_company=True)
invoice_method = fields.Selection([
("none", "No Invoice"),
@@ -602,6 +603,8 @@ class RepairLine(models.Model):
index=True, ondelete='cascade', check_company=True)
company_id = fields.Many2one(
related='repair_id.company_id', store=True, index=True)
currency_id = fields.Many2one(
related='repair_id.currency_id')
type = fields.Selection([
('add', 'Add'),
('remove', 'Remove')], 'Type', required=True)
@@ -737,6 +740,8 @@ class RepairFee(models.Model):
index=True, ondelete='cascade', required=True)
company_id = fields.Many2one(
related="repair_id.company_id", index=True, store=True)
currency_id = fields.Many2one(
related="repair_id.currency_id")
name = fields.Text('Description', index=True, required=True)
product_id = fields.Many2one(
'product.product', 'Product', check_company=True,
+5
View File
@@ -84,6 +84,7 @@
<field name="partner_invoice_id" attrs="{'invisible':[('invoice_method','=', 'none')],'required':[('invoice_method','!=','none')]}" groups="sale.group_delivery_invoice_address"/>
<field name="pricelist_id" groups="product.group_product_pricelist" context="{'product_id':product_id}" attrs="{'invisible':[('invoice_method','=', 'none')]}"/>
<field name="tag_ids" widget="many2many_tags" options="{'color_field': 'color', 'no_create_edit': True}"/>
<field name="currency_id" invisible="1"/>
</group>
</group>
<notebook>
@@ -106,6 +107,7 @@
<field name="tax_id" widget="many2many_tags"/>
<field name="invoiced" invisible="1"/>
<field name="price_subtotal" widget="monetary" invisible="1"/>
<field name="currency_id" invisible="1"/>
</group>
<group>
<field name="lot_id" context="{'default_product_id': product_id, 'default_company_id': company_id}" groups="stock.group_production_lot"/>
@@ -132,6 +134,7 @@
<field name="price_unit"/>
<field name="tax_id" widget="many2many_tags" optional="show"/>
<field name="price_subtotal" widget="monetary"/>
<field name="currency_id" invisible="1"/>
</tree>
</field>
<group class="oe_subtotal_footer oe_right">
@@ -162,6 +165,7 @@
<field name="price_unit"/>
<field widget="many2many_tags" name="tax_id"/>
<field name="price_subtotal" widget="monetary" invisible="1"/>
<field name="currency_id" invisible="1"/>
</group>
</form>
<tree string="Fees" editable="bottom">
@@ -174,6 +178,7 @@
<field name="price_unit"/>
<field name="tax_id" widget="many2many_tags" optional="show"/>
<field name="price_subtotal" widget="monetary"/>
<field name="currency_id" invisible="1"/>
</tree>
</field>
</page>
+1
View File
@@ -1015,6 +1015,7 @@
<field name="qty_to_invoice"/>
<field name="product_uom" string="Unit of Measure" groups="uom.group_uom"/>
<field name="price_subtotal" sum="Total" widget="monetary"/>
<field name="currency_id" invisible="1"/>
</tree>
</field>
</record>