[UPD] Synchronize budget with new quotation lines
By pressing button "Sync missing budget lines", a new budget section line is created for all the order lines without associated budget line.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
{
|
||||
"name": "account_budget_forecast",
|
||||
"version": "13.0.1.1.0",
|
||||
"version": "13.0.1.2.0",
|
||||
"author": "Elabore",
|
||||
"maintainer": "False",
|
||||
"website": "False",
|
||||
|
@@ -6,8 +6,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 13.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2022-05-23 21:11+0000\n"
|
||||
"PO-Revision-Date: 2022-05-23 21:11+0000\n"
|
||||
"POT-Creation-Date: 2022-05-24 14:53+0000\n"
|
||||
"PO-Revision-Date: 2022-05-24 14:53+0000\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@@ -111,6 +111,7 @@ msgstr ""
|
||||
#: model:ir.model.fields,field_description:account_budget_forecast.field_account_analytic_account__budget_forecast_ids
|
||||
#: model:ir.model.fields,field_description:account_budget_forecast.field_account_analytic_line__budget_forecast_id
|
||||
#: model:ir.model.fields,field_description:account_budget_forecast.field_account_move_line__budget_forecast_id
|
||||
#: model:ir.model.fields,field_description:account_budget_forecast.field_sale_order_line__budget_forecast_id
|
||||
msgid "Budget Forecast"
|
||||
msgstr ""
|
||||
|
||||
@@ -596,6 +597,11 @@ msgstr ""
|
||||
msgid "Sales Order"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_budget_forecast
|
||||
#: model:ir.model,name:account_budget_forecast.model_sale_order_line
|
||||
msgid "Sales Order Line"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_budget_forecast
|
||||
#: model:ir.model.fields.selection,name:account_budget_forecast.selection__budget_forecast__display_type__line_section
|
||||
#: model:ir.model.fields.selection,name:account_budget_forecast.selection__budget_forecast_model_line__display_type__line_section
|
||||
@@ -632,6 +638,11 @@ msgstr ""
|
||||
msgid "Summary"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_budget_forecast
|
||||
#: model_terms:ir.ui.view,arch_db:account_budget_forecast.view_order_form
|
||||
msgid "Sync missing budget lines"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_budget_forecast
|
||||
#: model_terms:ir.ui.view,arch_db:account_budget_forecast.view_analytic_budget_forecast
|
||||
msgid "Total"
|
||||
|
@@ -6,8 +6,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 13.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2022-05-23 21:09+0000\n"
|
||||
"PO-Revision-Date: 2022-05-23 21:09+0000\n"
|
||||
"POT-Creation-Date: 2022-05-24 14:52+0000\n"
|
||||
"PO-Revision-Date: 2022-05-24 14:52+0000\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@@ -32,7 +32,7 @@ msgstr "Réel"
|
||||
#. module: account_budget_forecast
|
||||
#: model:ir.model.fields,field_description:account_budget_forecast.field_budget_forecast__actual_qty
|
||||
msgid "Actual Quantity"
|
||||
msgstr "Quantité réelle"
|
||||
msgstr "Quantité actuelle"
|
||||
|
||||
#. module: account_budget_forecast
|
||||
#: model_terms:ir.ui.view,arch_db:account_budget_forecast.budget_forecast_category_miscellaneous
|
||||
@@ -113,6 +113,7 @@ msgstr "Coefficients de chiffrage"
|
||||
#: model:ir.model.fields,field_description:account_budget_forecast.field_account_analytic_account__budget_forecast_ids
|
||||
#: model:ir.model.fields,field_description:account_budget_forecast.field_account_analytic_line__budget_forecast_id
|
||||
#: model:ir.model.fields,field_description:account_budget_forecast.field_account_move_line__budget_forecast_id
|
||||
#: model:ir.model.fields,field_description:account_budget_forecast.field_sale_order_line__budget_forecast_id
|
||||
msgid "Budget Forecast"
|
||||
msgstr "Chiffrage"
|
||||
|
||||
@@ -180,7 +181,7 @@ msgstr "Modèles de coefficient"
|
||||
#. module: account_budget_forecast
|
||||
#: model:ir.ui.menu,name:account_budget_forecast.menu_budget_forecast
|
||||
msgid "Budget forecast"
|
||||
msgstr "Budget prévisionnel"
|
||||
msgstr "Lignes de chiffrage"
|
||||
|
||||
#. module: account_budget_forecast
|
||||
#: model:ir.model.fields,field_description:account_budget_forecast.field_product_product__budget_level
|
||||
@@ -598,6 +599,11 @@ msgstr "Réinitialiser le budget"
|
||||
msgid "Sales Order"
|
||||
msgstr "Bon de commande"
|
||||
|
||||
#. module: account_budget_forecast
|
||||
#: model:ir.model,name:account_budget_forecast.model_sale_order_line
|
||||
msgid "Sales Order Line"
|
||||
msgstr "Ligne de bons de commande"
|
||||
|
||||
#. module: account_budget_forecast
|
||||
#: model:ir.model.fields.selection,name:account_budget_forecast.selection__budget_forecast__display_type__line_section
|
||||
#: model:ir.model.fields.selection,name:account_budget_forecast.selection__budget_forecast_model_line__display_type__line_section
|
||||
@@ -634,6 +640,11 @@ msgstr "Sous-traitants"
|
||||
msgid "Summary"
|
||||
msgstr "Résumé"
|
||||
|
||||
#. module: account_budget_forecast
|
||||
#: model_terms:ir.ui.view,arch_db:account_budget_forecast.view_order_form
|
||||
msgid "Sync missing budget lines"
|
||||
msgstr "Synchroniser les lignes budgétaires manquantes"
|
||||
|
||||
#. module: account_budget_forecast
|
||||
#: model_terms:ir.ui.view,arch_db:account_budget_forecast.view_analytic_budget_forecast
|
||||
msgid "Total"
|
||||
@@ -680,7 +691,9 @@ msgstr ""
|
||||
#, python-format
|
||||
msgid ""
|
||||
"You must add an analytic account to build/access the budget forecast screen."
|
||||
msgstr "Vous devez ajouter un compte analytic pour construire et accéder au budget prévisionnel"
|
||||
msgstr ""
|
||||
"Vous devez ajouter un compte analytic pour construire et accéder au budget "
|
||||
"prévisionnel"
|
||||
|
||||
#. module: account_budget_forecast
|
||||
#: model:ir.model,name:account_budget_forecast.model_budget_coefficient_model
|
||||
|
@@ -263,6 +263,7 @@ class AccountAnalyticAccount(models.Model):
|
||||
"name": section.product_id.name,
|
||||
"product_uom_qty": 1.0,
|
||||
"price_unit": section.plan_amount_with_coeff,
|
||||
"budget_forecast_id": section.id,
|
||||
}
|
||||
self.env["sale.order.line"].create(values)
|
||||
quotation.analytic_account_id = self.id
|
||||
|
@@ -16,6 +16,31 @@ class SaleOrder(models.Model):
|
||||
raise Warning(_("Please set the analytic account"))
|
||||
return self.analytic_account_id.action_budget_forecast()
|
||||
|
||||
def sync_missing_budget_lines(self):
|
||||
for record in self:
|
||||
for line in self.order_line:
|
||||
if not line.budget_forecast_id:
|
||||
values = {
|
||||
"analytic_id": record.analytic_account_id.id,
|
||||
"product_id": line.product_id.id,
|
||||
"description": line.name,
|
||||
"is_summary": True,
|
||||
"display_type": "line_section",
|
||||
"sequence": 999,
|
||||
}
|
||||
budget_line = self.env["budget.forecast"].create(values)
|
||||
misc_budget_line = self.env["budget.forecast"].search(
|
||||
[
|
||||
("summary_id", "=", budget_line.id),
|
||||
("budget_category", "=", "miscellaneous"),
|
||||
]
|
||||
)
|
||||
misc_budget_line.plan_qty = 1
|
||||
misc_budget_line.plan_price = line.price_unit / (
|
||||
1 + record.analytic_account_id.global_coeff
|
||||
)
|
||||
line.budget_forecast_id = budget_line.id
|
||||
|
||||
@api.returns("self", lambda value: value.id)
|
||||
def copy(self, default=None):
|
||||
record = super(SaleOrder, self).copy(default=default)
|
||||
@@ -28,3 +53,9 @@ class SaleOrder(models.Model):
|
||||
default=dict(name=name)
|
||||
)
|
||||
return record
|
||||
|
||||
|
||||
class SaleOrderLine(models.Model):
|
||||
_inherit = "sale.order.line"
|
||||
|
||||
budget_forecast_id = fields.Many2one("budget.forecast")
|
||||
|
@@ -6,11 +6,17 @@
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.view_order_form" />
|
||||
<field name="arch" type="xml">
|
||||
<header position="inside">
|
||||
<button name="sync_missing_budget_lines" string="Sync missing budget lines" type="object" />
|
||||
</header>
|
||||
<div name="button_box">
|
||||
<button type="object" name="action_budget_forecast" class="oe_stat_button" icon="fa-usd">
|
||||
<field name="plan_amount_with_coeff" widget="statinfo" string="Budget" />
|
||||
</button>
|
||||
</div>
|
||||
<xpath expr="//field[@name='order_line']/tree/field[@name='name']" position="after">
|
||||
<field name="budget_forecast_id" optional="show" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
Reference in New Issue
Block a user