[PATCH] Upstream patch - 28122022

This commit is contained in:
Parthiv Patel committed 2022-12-28 08:35:15 +00:00
1 parent 063c271e4d
commit 3434b52ea8
15 files changed
+552 -58

No files matched your search

+1 -1
View File
@@ -143,7 +143,7 @@ def update_taxes_from_templates(cr, chart_template_xmlid):
outdated_taxes = []
for company in companies:
template_to_tax = _get_template_to_tax_xmlid_mapping(company)
templates = env['account.tax.template'].search([("chart_template_id", "=", chart_template_id)])
templates = env['account.tax.template'].with_context(active_test=False).search([("chart_template_id", "=", chart_template_id)])
for template in templates:
tax = env["account.tax"].browse(template_to_tax.get(template.id))
if not tax or not _is_tax_and_template_same(template, tax):
+2 -1
View File
@@ -231,7 +231,8 @@ class AccountFrFec(models.TransientModel):
and (unaffected_earnings_results[11] != '0,00'
or unaffected_earnings_results[12] != '0,00')):
#search an unaffected earnings account
unaffected_earnings_account = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_unaffected_earnings').id)], limit=1)
unaffected_earnings_account = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_unaffected_earnings').id),
('company_id', '=', company.id)], limit=1)
if unaffected_earnings_account:
unaffected_earnings_results[4] = unaffected_earnings_account.code
unaffected_earnings_results[5] = unaffected_earnings_account.name
+1 -1
View File
@@ -6,7 +6,7 @@
{
'name': 'Singapore - Accounting',
'author': 'Tech Receptives',
'version': '2.0',
'version': '2.1',
'category': 'Accounting/Localizations/Account Charts',
'description': """
Singapore accounting chart and localization.
+3
View File
@@ -9,6 +9,9 @@
<record id="tax_group_7" model="account.tax.group">
<field name="name">TAX 7%</field>
</record>
<record id="tax_group_8" model="account.tax.group">
<field name="name">TAX 8%</field>
</record>
</data>
</flectra>
+403
View File
@@ -72,6 +72,43 @@
]"/>
</record>
<record id="sg_sale_tax_ds_8" model="account.tax.template">
<field name="name">Sales Tax 8% DS</field>
<field name="description">8% DS</field>
<field name="price_include" eval="0"/>
<field name="amount">8</field>
<field name="amount_type">percent</field>
<field name="type_tax_use">sale</field>
<field name="chart_template_id" ref="sg_chart_template"/>
<field name="tax_group_id" ref="tax_group_8"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'plus_report_line_ids': [ref('account_tax_report_line_std_rated_supplies')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('account_account_792'),
'plus_report_line_ids': [ref('account_tax_report_line_output_tax_due')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'minus_report_line_ids': [ref('account_tax_report_line_std_rated_supplies')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('account_account_792'),
'minus_report_line_ids': [ref('account_tax_report_line_output_tax_due')],
}),
]"/>
</record>
<record id="sg_sale_tax_esn_0" model="account.tax.template">
<field name="name">Sales Tax 0% ESN33</field>
<field name="description">0% ESN33</field>
@@ -206,6 +243,43 @@
]"/>
</record>
<record id="sg_sale_tax_sr_8" model="account.tax.template">
<field name="name">Sales Tax 8% SR</field>
<field name="description">8% SR</field>
<field name="price_include" eval="0"/>
<field name="amount">8</field>
<field name="amount_type">percent</field>
<field name="type_tax_use">sale</field>
<field name="chart_template_id" ref="sg_chart_template"/>
<field name="tax_group_id" ref="tax_group_8"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'plus_report_line_ids': [ref('account_tax_report_line_std_rated_supplies')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('account_account_796'),
'plus_report_line_ids': [ref('account_tax_report_line_output_tax_due')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'minus_report_line_ids': [ref('account_tax_report_line_std_rated_supplies')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('account_account_796'),
'minus_report_line_ids': [ref('account_tax_report_line_output_tax_due')],
}),
]"/>
</record>
<record id="sg_sale_tax_srca_s_na" model="account.tax.template">
<field name="name">Sales Tax SRCA-S</field>
<field name="description">SRCA-S</field>
@@ -276,6 +350,43 @@
]"/>
</record>
<record id="sg_sale_tax_srca_c_8" model="account.tax.template">
<field name="name">Sales Tax 8% SRCA-C</field>
<field name="description">8% SRCA-C</field>
<field name="price_include" eval="0"/>
<field name="amount">8</field>
<field name="amount_type">percent</field>
<field name="type_tax_use">sale</field>
<field name="chart_template_id" ref="sg_chart_template"/>
<field name="tax_group_id" ref="tax_group_8"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'plus_report_line_ids': [ref('account_tax_report_line_std_rated_supplies')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('account_account_798'),
'plus_report_line_ids': [ref('account_tax_report_line_output_tax_due')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'minus_report_line_ids': [ref('account_tax_report_line_std_rated_supplies')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('account_account_798'),
'minus_report_line_ids': [ref('account_tax_report_line_output_tax_due')],
}),
]"/>
</record>
<!-- Purchases Tax -->
<record id="sg_purchase_tax_txn33_7" model="account.tax.template">
@@ -315,6 +426,43 @@
]"/>
</record>
<record id="sg_purchase_tax_txn33_8" model="account.tax.template">
<field name="name">Purchase Tax 8% TX-N33</field>
<field name="description">8% TX-N33</field>
<field name="price_include" eval="0"/>
<field name="amount">8</field>
<field name="amount_type">percent</field>
<field name="type_tax_use">purchase</field>
<field name="chart_template_id" ref="sg_chart_template"/>
<field name="tax_group_id" ref="tax_group_8"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'plus_report_line_ids': [ref('account_tax_report_line_total_taxable_purchases')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('account_account_738'),
'plus_report_line_ids': [ref('account_tax_report_line_inp_tax_refund_claim')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'minus_report_line_ids': [ref('account_tax_report_line_total_taxable_purchases')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('account_account_738'),
'minus_report_line_ids': [ref('account_tax_report_line_inp_tax_refund_claim')],
}),
]"/>
</record>
<record id="sg_purchase_tax_txe33_7" model="account.tax.template">
<field name="name">Purchase Tax 7% TX-E33</field>
<field name="description">7% TX-E33</field>
@@ -352,6 +500,43 @@
]"/>
</record>
<record id="sg_purchase_tax_txe33_8" model="account.tax.template">
<field name="name">Purchase Tax 8% TX-E33</field>
<field name="description">8% TX-E33</field>
<field name="price_include" eval="0"/>
<field name="amount">8</field>
<field name="amount_type">percent</field>
<field name="type_tax_use">purchase</field>
<field name="chart_template_id" ref="sg_chart_template"/>
<field name="tax_group_id" ref="tax_group_8"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'plus_report_line_ids': [ref('account_tax_report_line_total_taxable_purchases')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('account_account_739'),
'plus_report_line_ids': [ref('account_tax_report_line_inp_tax_refund_claim')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'minus_report_line_ids': [ref('account_tax_report_line_total_taxable_purchases')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('account_account_739'),
'minus_report_line_ids': [ref('account_tax_report_line_inp_tax_refund_claim')],
}),
]"/>
</record>
<record id="sg_purchase_tax_bl_7" model="account.tax.template">
<field name="name">Purchase Tax 7% BL</field>
<field name="description">7% BL</field>
@@ -385,6 +570,39 @@
]"/>
</record>
<record id="sg_purchase_tax_bl_8" model="account.tax.template">
<field name="name">Purchase Tax 8% BL</field>
<field name="description">8% BL</field>
<field name="price_include" eval="0"/>
<field name="amount">8</field>
<field name="amount_type">percent</field>
<field name="type_tax_use">purchase</field>
<field name="chart_template_id" ref="sg_chart_template"/>
<field name="tax_group_id" ref="tax_group_8"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('account_account_740'),
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('account_account_740'),
}),
]"/>
</record>
<record id="sg_purchase_tax_im_7" model="account.tax.template">
<field name="name">Purchase Tax 7% IM</field>
<field name="description">7% IM</field>
@@ -422,6 +640,43 @@
]"/>
</record>
<record id="sg_purchase_tax_im_8" model="account.tax.template">
<field name="name">Purchase Tax 8% IM</field>
<field name="description">8% IM</field>
<field name="price_include" eval="0"/>
<field name="amount">8</field>
<field name="amount_type">percent</field>
<field name="type_tax_use">purchase</field>
<field name="chart_template_id" ref="sg_chart_template"/>
<field name="tax_group_id" ref="tax_group_8"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'plus_report_line_ids': [ref('account_tax_report_line_total_taxable_purchases')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('account_account_741'),
'plus_report_line_ids': [ref('account_tax_report_line_inp_tax_refund_claim')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'minus_report_line_ids': [ref('account_tax_report_line_total_taxable_purchases')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('account_account_741'),
'minus_report_line_ids': [ref('account_tax_report_line_inp_tax_refund_claim')],
}),
]"/>
</record>
<record id="sg_purchase_tax_txre_7" model="account.tax.template">
<field name="name">Purchase Tax 7% TX-RE</field>
<field name="description">7% TX-RE</field>
@@ -459,6 +714,43 @@
]"/>
</record>
<record id="sg_purchase_tax_txre_8" model="account.tax.template">
<field name="name">Purchase Tax 8% TX-RE</field>
<field name="description">8% TX-RE</field>
<field name="price_include" eval="0"/>
<field name="amount">8</field>
<field name="amount_type">percent</field>
<field name="type_tax_use">purchase</field>
<field name="chart_template_id" ref="sg_chart_template"/>
<field name="tax_group_id" ref="tax_group_8"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'plus_report_line_ids': [ref('account_tax_report_line_total_taxable_purchases')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('account_account_742'),
'plus_report_line_ids': [ref('account_tax_report_line_inp_tax_refund_claim')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'minus_report_line_ids': [ref('account_tax_report_line_total_taxable_purchases')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('account_account_742'),
'minus_report_line_ids': [ref('account_tax_report_line_inp_tax_refund_claim')],
}),
]"/>
</record>
<record id="sg_purchase_tax_me_0" model="account.tax.template">
<field name="name">Purchase Tax 7% IGDS</field>
<field name="description">7% IGDS</field>
@@ -496,6 +788,43 @@
]"/>
</record>
<record id="sg_purchase_tax_me_08" model="account.tax.template">
<field name="name">Purchase Tax 8% IGDS</field>
<field name="description">8% IGDS</field>
<field name="price_include" eval="0"/>
<field name="amount">8</field>
<field name="amount_type">percent</field>
<field name="type_tax_use">purchase</field>
<field name="chart_template_id" ref="sg_chart_template"/>
<field name="tax_group_id" ref="tax_group_8"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'plus_report_line_ids': [ref('account_tax_report_line_total_taxable_purchases')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('account_account_743'),
'plus_report_line_ids': [ref('account_tax_report_line_inp_tax_refund_claim')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'minus_report_line_ids': [ref('account_tax_report_line_total_taxable_purchases')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('account_account_743'),
'minus_report_line_ids': [ref('account_tax_report_line_inp_tax_refund_claim')],
}),
]"/>
</record>
<record id="sg_purchase_tax_nr_0" model="account.tax.template">
<field name="name">Purchase Tax 0% NR</field>
<field name="description">0% NR</field>
@@ -692,6 +1021,43 @@
]"/>
</record>
<record id="sg_purchase_tax_tx8_8" model="account.tax.template">
<field name="name">Purchase Tax 8% TX8</field>
<field name="description">8% TX8</field>
<field name="price_include" eval="0"/>
<field name="amount">8</field>
<field name="amount_type">percent</field>
<field name="type_tax_use">purchase</field>
<field name="chart_template_id" ref="sg_chart_template"/>
<field name="tax_group_id" ref="tax_group_8"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'plus_report_line_ids': [ref('account_tax_report_line_total_taxable_purchases')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('account_account_749'),
'plus_report_line_ids': [ref('account_tax_report_line_inp_tax_refund_claim')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'minus_report_line_ids': [ref('account_tax_report_line_total_taxable_purchases')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('account_account_749'),
'minus_report_line_ids': [ref('account_tax_report_line_inp_tax_refund_claim')],
}),
]"/>
</record>
<record id="sg_purchase_tax_txca_7" model="account.tax.template">
<field name="name">Purchase Tax 7% TXCA</field>
<field name="description">7% TXCA</field>
@@ -728,5 +1094,42 @@
}),
]"/>
</record>
<record id="sg_purchase_tax_txca_8" model="account.tax.template">
<field name="name">Purchase Tax 8% TXCA</field>
<field name="description">8% TXCA</field>
<field name="price_include" eval="0"/>
<field name="amount">8</field>
<field name="amount_type">percent</field>
<field name="type_tax_use">purchase</field>
<field name="chart_template_id" ref="sg_chart_template"/>
<field name="tax_group_id" ref="tax_group_8"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'plus_report_line_ids': [ref('account_tax_report_line_total_taxable_purchases')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('account_account_750'),
'plus_report_line_ids': [ref('account_tax_report_line_inp_tax_refund_claim')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'minus_report_line_ids': [ref('account_tax_report_line_total_taxable_purchases')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('account_account_750'),
'minus_report_line_ids': [ref('account_tax_report_line_inp_tax_refund_claim')],
}),
]"/>
</record>
</data>
</flectra>
+11 -11
View File
@@ -316,7 +316,7 @@
</record>
<record model="account.account.template" id="account_account_738">
<field name="name">Purchase Tax Account 7% TX-N33</field>
<field name="name">Purchase Tax Account 8% TX-N33</field>
<field name="code">101260</field>
<field name="user_type_id" ref="account.data_account_type_current_assets" />
<field name="chart_template_id" ref="sg_chart_template"/>
@@ -324,7 +324,7 @@
</record>
<record model="account.account.template" id="account_account_739">
<field name="name">Purchase Tax Account 7% TX-E33</field>
<field name="name">Purchase Tax Account 8% TX-E33</field>
<field name="code">101270</field>
<field name="user_type_id" ref="account.data_account_type_current_assets" />
<field name="chart_template_id" ref="sg_chart_template"/>
@@ -332,7 +332,7 @@
</record>
<record model="account.account.template" id="account_account_740">
<field name="name">Purchase Tax Account 7% BL</field>
<field name="name">Purchase Tax Account 8% BL</field>
<field name="code">101280</field>
<field name="user_type_id" ref="account.data_account_type_current_assets" />
<field name="chart_template_id" ref="sg_chart_template"/>
@@ -340,7 +340,7 @@
</record>
<record model="account.account.template" id="account_account_741">
<field name="name">Purchase Tax Account 7% IM</field>
<field name="name">Purchase Tax Account 8% IM</field>
<field name="code">101290</field>
<field name="user_type_id" ref="account.data_account_type_current_assets" />
<field name="chart_template_id" ref="sg_chart_template"/>
@@ -348,7 +348,7 @@
</record>
<record model="account.account.template" id="account_account_742">
<field name="name">Purchase Tax Account 7% TX-RE</field>
<field name="name">Purchase Tax Account 8% TX-RE</field>
<field name="code">101300</field>
<field name="user_type_id" ref="account.data_account_type_current_assets" />
<field name="chart_template_id" ref="sg_chart_template"/>
@@ -356,7 +356,7 @@
</record>
<record model="account.account.template" id="account_account_743">
<field name="name">Purchase Tax Account 7% IGDS</field>
<field name="name">Purchase Tax Account 8% IGDS</field>
<field name="code">101310</field>
<field name="user_type_id" ref="account.data_account_type_current_assets" />
<field name="chart_template_id" ref="sg_chart_template"/>
@@ -404,7 +404,7 @@
</record>
<record model="account.account.template" id="account_account_749">
<field name="name">Purchase Tax Account 7% TX7</field>
<field name="name">Purchase Tax Account 8% TX8</field>
<field name="code">101370</field>
<field name="user_type_id" ref="account.data_account_type_current_assets" />
<field name="chart_template_id" ref="sg_chart_template"/>
@@ -412,7 +412,7 @@
</record>
<record model="account.account.template" id="account_account_750">
<field name="name">Purchase Tax Account 7% TXCA</field>
<field name="name">Purchase Tax Account 8% TXCA</field>
<field name="code">101380</field>
<field name="user_type_id" ref="account.data_account_type_current_assets" />
<field name="chart_template_id" ref="sg_chart_template"/>
@@ -708,7 +708,7 @@
</record>
<record model="account.account.template" id="account_account_792">
<field name="name">Sales Tax Account 7% DS</field>
<field name="name">Sales Tax Account 8% DS</field>
<field name="code">201180</field>
<field name="user_type_id" ref="account.data_account_type_current_liabilities" />
<field name="chart_template_id" ref="sg_chart_template"/>
@@ -740,7 +740,7 @@
</record>
<record model="account.account.template" id="account_account_796">
<field name="name">Sales Tax Account 7% SR</field>
<field name="name">Sales Tax Account 8% SR</field>
<field name="code">201220</field>
<field name="user_type_id" ref="account.data_account_type_current_liabilities" />
<field name="chart_template_id" ref="sg_chart_template"/>
@@ -756,7 +756,7 @@
</record>
<record model="account.account.template" id="account_account_798">
<field name="name">Sales Tax Account 7% SRCA-C</field>
<field name="name">Sales Tax Account 8% SRCA-C</field>
<field name="code">201240</field>
<field name="user_type_id" ref="account.data_account_type_current_liabilities" />
<field name="chart_template_id" ref="sg_chart_template"/>
@@ -0,0 +1,6 @@
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
from flectra.addons.account.models.chart_template import update_taxes_from_templates
def migrate(cr, version):
update_taxes_from_templates(cr, 'l10n_sg.sg_chart_template')
@@ -109,4 +109,4 @@ id,code,name,user_type_id/id,reconcile,chart_template_id/id
620040,620040,Land and buildings Depreciation,account.data_account_type_depreciation,False,default_chart_template
620050,620050,Motor vehicles Depreciation,account.data_account_type_depreciation,False,default_chart_template
620060,620060,Office equipment (inc computer equipment) Depreciation,account.data_account_type_depreciation,False,default_chart_template
620070,620070,Plant and machinery Depreciation,account.data_account_type_depreciation,False,default_chart_template
620070,620070,Plant and machinery Depreciation,account.data_account_type_depreciation,False,default_chart_template
1 id code name user_type_id/id reconcile chart_template_id/id
109 620040 620040 Land and buildings Depreciation account.data_account_type_depreciation False default_chart_template
110 620050 620050 Motor vehicles Depreciation account.data_account_type_depreciation False default_chart_template
111 620060 620060 Office equipment (inc computer equipment) Depreciation account.data_account_type_depreciation False default_chart_template
112 620070 620070 Plant and machinery Depreciation account.data_account_type_depreciation False default_chart_template default_chart_template
+9 -4
View File
@@ -238,6 +238,7 @@ class StockMove(models.Model):
def _action_confirm(self, merge=True, merge_into=False):
moves = self.action_explode()
merge_into = merge_into and merge_into.action_explode()
# we go further with the list of ids potentially changed by action_explode
return super(StockMove, moves)._action_confirm(merge=merge, merge_into=merge_into)
@@ -257,20 +258,23 @@ class StockMove(models.Model):
if not bom:
moves_ids_to_return.add(move.id)
continue
if move.picking_id.immediate_transfer:
if move.picking_id.immediate_transfer or float_is_zero(move.product_uom_qty, precision_rounding=move.product_uom.rounding):
factor = move.product_uom._compute_quantity(move.quantity_done, bom.product_uom_id) / bom.product_qty
else:
factor = move.product_uom._compute_quantity(move.product_uom_qty, bom.product_uom_id) / bom.product_qty
boms, lines = bom.sudo().explode(move.product_id, factor, picking_type=bom.picking_type_id)
for bom_line, line_data in lines:
if move.picking_id.immediate_transfer:
if move.picking_id.immediate_transfer or float_is_zero(move.product_uom_qty, precision_rounding=move.product_uom.rounding):
phantom_moves_vals_list += move._generate_move_phantom(bom_line, 0, line_data['qty'])
else:
phantom_moves_vals_list += move._generate_move_phantom(bom_line, line_data['qty'], 0)
# delete the move with original product which is not relevant anymore
moves_ids_to_unlink.add(move.id)
self.env['stock.move'].browse(moves_ids_to_unlink).sudo().unlink()
move_to_unlink = self.env['stock.move'].browse(moves_ids_to_unlink).sudo()
move_to_unlink.quantity_done = 0
move_to_unlink._action_cancel()
move_to_unlink.unlink()
if phantom_moves_vals_list:
phantom_moves = self.env['stock.move'].create(phantom_moves_vals_list)
phantom_moves._adjust_procure_method()
@@ -319,7 +323,8 @@ class StockMove(models.Model):
if bom_line.product_id.type in ['product', 'consu']:
vals = self.copy_data(default=self._prepare_phantom_move_values(bom_line, product_qty, quantity_done))
if self.state == 'assigned':
vals['state'] = 'assigned'
for v in vals:
v['state'] = 'assigned'
return vals
@api.model
+43
View File
@@ -348,3 +348,46 @@ class TestKitPicking(common.TestMrpCommon):
self.assertEqual(len(picking.move_lines), 7)
for move_line in picking.move_lines:
self.assertEqual(move_line.product_qty, self.expected_quantities[move_line.product_id])
def test_add_sml_with_kit_to_confirmed_picking(self):
warehouse = self.env['stock.warehouse'].search([('company_id', '=', self.env.company.id)], limit=1)
customer_location = self.env.ref('stock.stock_location_customers')
stock_location = warehouse.lot_stock_id
in_type = warehouse.in_type_id
self.bom_4.type = 'phantom'
kit = self.bom_4.product_id
compo = self.bom_4.bom_line_ids.product_id
product = self.env['product.product'].create({'name': 'Super Product', 'type': 'product'})
receipt = self.env['stock.picking'].create({
'picking_type_id': in_type.id,
'location_id': customer_location.id,
'location_dest_id': stock_location.id,
'move_lines': [(0, 0, {
'name': product.name,
'product_id': product.id,
'product_uom_qty': 1,
'product_uom': product.uom_id.id,
'location_id': customer_location.id,
'location_dest_id': stock_location.id,
})]
})
receipt.action_confirm()
receipt.move_line_ids.qty_done = 1
receipt.move_line_ids = [(0, 0, {
'product_id': kit.id,
'qty_done': 1,
'product_uom_id': kit.uom_id.id,
'location_id': customer_location.id,
'location_dest_id': stock_location.id,
})]
receipt.button_validate()
self.assertEqual(receipt.state, 'done')
self.assertRecordValues(receipt.move_lines, [
{'product_id': product.id, 'quantity_done': 1, 'state': 'done'},
{'product_id': compo.id, 'quantity_done': 1, 'state': 'done'},
])
@@ -276,3 +276,35 @@ class TestMrpValuationStandard(TestMrpValuationCommon):
self.assertEqual(self.product1.quantity_svl, 2)
self._make_out_move(self.product1, 1)
self.assertEqual(self.product1.value_svl, 15)
def test_validate_draft_kit(self):
"""
Create a draft receipt, add a kit to its move lines and directly
validate it. From client side, such a behaviour is possible with
the Barcode app.
"""
self.component.product_tmpl_id.categ_id.property_cost_method = 'average'
self.product1.type = 'consu'
self.bom.type = 'phantom'
self.component.standard_price = 1424
receipt = self.env['stock.picking'].create({
'location_id': self.customer_location.id,
'location_dest_id': self.stock_location.id,
'picking_type_id': self.picking_type_in.id,
'move_line_ids': [(0, 0, {
'product_id': self.product1.id,
'qty_done': 1,
'product_uom_id': self.product1.uom_id.id,
'location_id': self.customer_location.id,
'location_dest_id': self.stock_location.id,
})]
})
receipt.button_validate()
self.assertEqual(receipt.state, 'done')
self.assertRecordValues(receipt.move_lines, [
{'product_id': self.component.id, 'quantity_done': 1, 'state': 'done'},
])
self.assertEqual(self.component.qty_available, 1)
self.assertEqual(self.component.value_svl, 1424)
@@ -1,14 +1,12 @@
/* Modifications for the Light and Boxed document layouts */
.article.o_report_layout_standard.o_company_1_layout, .article.o_report_layout_boxed.o_company_1_layout {
> .pt-5 {
padding-top: 0 !important;
> .address.row {
width: 100% !important;
height: 62mm !important;
width: 117% !important;
height: 68mm !important;
margin-top: -4mm !important;
line-height: 1.1em;
margin-top: -13mm;
> div[name="address"] {
padding-top: 5mm;
}
}
}
}
@@ -16,39 +14,36 @@
/* Modifications for Clean document layouts */
.article.o_report_layout_clean.o_company_1_layout {
> .address.row {
width: 100% !important;
height: 62mm !important;
width: 117% !important;
height: 68mm !important;
margin-top: -4mm !important;
line-height: 1.1em;
> div[name="address"] {
padding-top: 15mm !important;
}
}
}
/* Modification for background document layouts */
.o_company_1_layout.article.o_report_layout_background {
> .address.row {
background-color: #ffffff !important;
width: 103% !important;
height: 62mm !important;
width: 117% !important;
height: 68mm !important;
margin-top: -4mm !important;
line-height: 1.1em;
> div[name="address"] {
padding-top: 8mm !important;
}
}
}
div .address.row > div[name="address"] {
position: relative !important;
width: 103mm !important;
margin-left: 48.5% !important;
background-color: #ffffff;
> address {
width: 100% !important;
position: absolute !important;
bottom: 0 !important;
padding-left: 3mm;
padding-top: 3mm;
height: 33mm;
max-height: 33mm;
> address, div {
> address {
width: 100% !important;
position: absolute !important;
bottom: 0 !important;
padding-left: 3mm;
padding-top: 3mm;
height: 33mm;
max-height: 33mm;
}
}
}
+2 -2
View File
@@ -1515,8 +1515,8 @@ class StockMove(models.Model):
return extra_move | self
def _action_done(self, cancel_backorder=False):
self.filtered(lambda move: move.state == 'draft')._action_confirm() # MRP allows scrapping draft moves
moves = self.exists().filtered(lambda x: x.state not in ('done', 'cancel'))
moves = self.filtered(lambda move: move.state == 'draft')._action_confirm() # MRP allows scrapping draft moves
moves = (self | moves).exists().filtered(lambda x: x.state not in ('done', 'cancel'))
moves_todo = self.env['stock.move']
# Cancel moves where necessary ; we should do it before creating the extra moves because
@@ -256,6 +256,9 @@ class StockMove(models.Model):
res = super(StockMove, self)._action_done(cancel_backorder=cancel_backorder)
# '_action_done' might have deleted some exploded stock moves
valued_moves = {value_type: moves.exists() for value_type, moves in valued_moves.items()}
# '_action_done' might have created an extra move to be valued
for move in res - self:
for valued_type in self._get_valued_types():
@@ -1585,17 +1585,6 @@ options.registry.sizing_x = options.registry.sizing.extend({
});
options.registry.layout_column = options.Class.extend({
/**
* @override
*/
start: function () {
// Needs to be done manually for now because _computeWidgetVisibility
// doesn't go through this option for buttons inside of a select.
// TODO: improve this.
this.$el.find('we-button[data-name="zero_cols_opt"]')
.toggleClass('d-none', !this.$target.is('.s_allow_columns'));
return this._super(...arguments);
},
//--------------------------------------------------------------------------
// Options
@@ -1640,6 +1629,20 @@ options.registry.layout_column = options.Class.extend({
}
return this._super(...arguments);
},
/**
* @override
*/
_computeWidgetVisibility(widgetName, params) {
if (widgetName === 'zero_cols_opt') {
// Note: "s_allow_columns" indicates containers which may have
// bare content (without columns) and are allowed to have columns.
// By extension, we only show the "None" option on elements that
// were marked as such as they were allowed to have bare content in
// the first place.
return this.$target.is('.s_allow_columns');
}
return this._super(...arguments);
},
/**
* Adds new columns which are clones of the last column or removes the
* last x columns.