friday fix
This commit is contained in:
parent
baad827f86
commit
3ecbac2346
5 changed files with 65 additions and 41 deletions
|
|
@ -44,7 +44,7 @@
|
||||||
],
|
],
|
||||||
'data': [
|
'data': [
|
||||||
# BV: FOR MIGRATION
|
# BV: FOR MIGRATION
|
||||||
# 'data/fsm_data.xml',
|
'data/fsm_data.xml',
|
||||||
'views/task_template_views.xml',
|
'views/task_template_views.xml',
|
||||||
'views/equipment.xml',
|
'views/equipment.xml',
|
||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
<field name="name">Waiting on Parts</field>
|
<field name="name">Waiting on Parts</field>
|
||||||
<field name="legend_blocked">Blocked</field>
|
<field name="legend_blocked">Blocked</field>
|
||||||
<field name="fold" eval="False"/>
|
<field name="fold" eval="False"/>
|
||||||
<field name="is_closed" eval="False"/>
|
<!-- <field name="is_closed" eval="False"/>-->
|
||||||
<field name="project_ids" eval="[(4,ref('industry_fsm.fsm_project'))]"/>
|
<field name="project_ids" eval="[(4,ref('industry_fsm.fsm_project'))]"/>
|
||||||
</record>
|
</record>
|
||||||
<record id="planning_project_stage_work_completed" model="project.task.type">
|
<record id="planning_project_stage_work_completed" model="project.task.type">
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
<field name="name">Work Executed</field>
|
<field name="name">Work Executed</field>
|
||||||
<field name="legend_blocked">Blocked</field>
|
<field name="legend_blocked">Blocked</field>
|
||||||
<field name="fold" eval="False"/>
|
<field name="fold" eval="False"/>
|
||||||
<field name="is_closed" eval="False"/>
|
<!-- <field name="is_closed" eval="False"/>-->
|
||||||
<field name="project_ids" eval="[(4,ref('industry_fsm.fsm_project'))]"/>
|
<field name="project_ids" eval="[(4,ref('industry_fsm.fsm_project'))]"/>
|
||||||
</record>
|
</record>
|
||||||
<record id="planning_project_stage_exception" model="project.task.type">
|
<record id="planning_project_stage_exception" model="project.task.type">
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
<field name="name">Exception</field>
|
<field name="name">Exception</field>
|
||||||
<field name="legend_blocked">Blocked</field>
|
<field name="legend_blocked">Blocked</field>
|
||||||
<field name="fold" eval="False"/>
|
<field name="fold" eval="False"/>
|
||||||
<field name="is_closed" eval="False"/>
|
<!-- <field name="is_closed" eval="False"/>-->
|
||||||
<field name="project_ids" eval="[(4,ref('industry_fsm.fsm_project'))]"/>
|
<field name="project_ids" eval="[(4,ref('industry_fsm.fsm_project'))]"/>
|
||||||
</record>
|
</record>
|
||||||
<!-- Since the Field Service project has no_update="1" we use a workaround here -->
|
<!-- Since the Field Service project has no_update="1" we use a workaround here -->
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ class Task(models.Model):
|
||||||
)
|
)
|
||||||
|
|
||||||
planned_date_begin = fields.Datetime(
|
planned_date_begin = fields.Datetime(
|
||||||
string="Start Date",
|
string="Planned Start Date",
|
||||||
tracking=True,
|
tracking=True,
|
||||||
task_dependency_tracking=True,
|
task_dependency_tracking=True,
|
||||||
compute="_compute_planned_dates",
|
compute="_compute_planned_dates",
|
||||||
|
|
@ -47,7 +47,7 @@ class Task(models.Model):
|
||||||
)
|
)
|
||||||
|
|
||||||
planned_date_end = fields.Datetime(
|
planned_date_end = fields.Datetime(
|
||||||
string="End Date",
|
string="Planned End Date",
|
||||||
tracking=True,
|
tracking=True,
|
||||||
task_dependency_tracking=True,
|
task_dependency_tracking=True,
|
||||||
compute="_compute_planned_dates",
|
compute="_compute_planned_dates",
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
</group>
|
</group>
|
||||||
<group name="right">
|
<group name="right">
|
||||||
<field name="partner_location_id"
|
<field name="partner_location_id"
|
||||||
groups="sale.group_delivery_invoice_address"
|
groups="account.group_delivery_invoice_address"
|
||||||
context="{'default_type': 'delivery', 'show_address': 1}"
|
context="{'default_type': 'delivery', 'show_address': 1}"
|
||||||
options='{"always_reload": True}'/>
|
options='{"always_reload": True}'/>
|
||||||
<field name="tag_ids" widget="many2many_tags" options="{'no_open': False}"/>
|
<field name="tag_ids" widget="many2many_tags" options="{'no_open': False}"/>
|
||||||
|
|
|
||||||
|
|
@ -5,48 +5,74 @@ from odoo.tools.float_utils import float_is_zero, float_compare
|
||||||
class SaleOrder(models.Model):
|
class SaleOrder(models.Model):
|
||||||
_inherit = 'sale.order'
|
_inherit = 'sale.order'
|
||||||
|
|
||||||
margin_actual = fields.Monetary("Margin", compute='_compute_margin_actual',
|
margin_actual = fields.Monetary("Our Margin", compute='_compute_margin_actual', store=False)
|
||||||
store=False)
|
|
||||||
margin_percent_actual = fields.Float('Margin (%)', compute='_compute_margin_actual',
|
margin_percent_actual = fields.Float(
|
||||||
store=False,
|
string='Our Margin (%)',
|
||||||
group_operator='avg')
|
compute='_compute_margin_actual',
|
||||||
|
store=False,
|
||||||
|
group_operator='avg'
|
||||||
|
)
|
||||||
|
|
||||||
@api.depends('order_line.margin_actual', 'amount_untaxed')
|
@api.depends('order_line.margin_actual', 'amount_untaxed')
|
||||||
def _compute_margin_actual(self):
|
def _compute_margin_actual(self):
|
||||||
for order in self:
|
for order in self:
|
||||||
order.margin_actual = sum(order.order_line.mapped('margin_actual'))
|
order.margin_actual = sum(order.order_line.mapped('margin_actual'))
|
||||||
order.margin_percent_actual = order.amount_untaxed \
|
order.margin_percent_actual = order.amount_untaxed and order.margin_actual / order.amount_untaxed
|
||||||
and order.margin_actual / order.amount_untaxed
|
|
||||||
|
|
||||||
|
|
||||||
class SaleOrderLine(models.Model):
|
class SaleOrderLine(models.Model):
|
||||||
_inherit = 'sale.order.line'
|
_inherit = 'sale.order.line'
|
||||||
|
|
||||||
purchase_price_vendor = fields.Float(compute='_compute_purchase_price_vendor',
|
purchase_price_vendor = fields.Float(
|
||||||
string="Vendor Price", groups="base.group_user",
|
compute='_compute_purchase_price_vendor',
|
||||||
digits='Product Price')
|
string="Vendor Price",
|
||||||
margin_percent_vendor = fields.Float(string='Margin (%) on Vendor Price',
|
groups="base.group_user",
|
||||||
groups='base.group_user', group_operator='avg',
|
digits='Product Price'
|
||||||
compute='_compute_margin_vendor')
|
)
|
||||||
margin_vendor = fields.Float(string='Margin on Vendor Price',
|
|
||||||
groups='base.group_user', digits='Product Price',
|
|
||||||
compute='_compute_margin_vendor')
|
|
||||||
|
|
||||||
purchase_price_actual = fields.Float(compute="_compute_actual_margins",
|
margin_percent_vendor = fields.Float(
|
||||||
digits='Product Price',
|
string='Margin (%) on Vendor Price',
|
||||||
groups="base.group_user",
|
groups='base.group_user',
|
||||||
string="Purchase Price")
|
group_operator='avg',
|
||||||
margin_actual = fields.Float(compute="_compute_actual_margins",
|
compute='_compute_margin_vendor'
|
||||||
digits='Product Price',
|
)
|
||||||
groups="base.group_user",
|
|
||||||
string="Margin")
|
|
||||||
margin_percent_actual = fields.Float(compute="_compute_actual_margins",
|
|
||||||
groups="base.group_user",
|
|
||||||
string="Margin (%)")
|
|
||||||
|
|
||||||
@api.depends('purchase_price', 'purchase_price_vendor', 'move_ids.product_id',
|
margin_vendor = fields.Float(
|
||||||
'move_ids.product_id.qty_available', 'move_ids.state',
|
string='Margin on Vendor Price',
|
||||||
'qty_to_deliver')
|
groups='base.group_user',
|
||||||
|
digits='Product Price',
|
||||||
|
compute='_compute_margin_vendor'
|
||||||
|
)
|
||||||
|
|
||||||
|
purchase_price_actual = fields.Float(
|
||||||
|
compute="_compute_actual_margins",
|
||||||
|
digits='Product Price',
|
||||||
|
groups="base.group_user",
|
||||||
|
string="Purchase Price"
|
||||||
|
)
|
||||||
|
|
||||||
|
margin_actual = fields.Float(
|
||||||
|
compute="_compute_actual_margins",
|
||||||
|
digits='Product Price',
|
||||||
|
groups="base.group_user",
|
||||||
|
string="Our Margin"
|
||||||
|
)
|
||||||
|
|
||||||
|
margin_percent_actual = fields.Float(
|
||||||
|
compute="_compute_actual_margins",
|
||||||
|
groups="base.group_user",
|
||||||
|
string="Our Margin (%)"
|
||||||
|
)
|
||||||
|
|
||||||
|
@api.depends(
|
||||||
|
'purchase_price',
|
||||||
|
'purchase_price_vendor',
|
||||||
|
'move_ids.product_id',
|
||||||
|
'move_ids.product_id.qty_available',
|
||||||
|
'move_ids.state',
|
||||||
|
'qty_to_deliver'
|
||||||
|
)
|
||||||
def _compute_actual_margins(self):
|
def _compute_actual_margins(self):
|
||||||
""" We want to use the margin based on average inventory valuation when the
|
""" We want to use the margin based on average inventory valuation when the
|
||||||
sale order line will be completely fulfilled (or has been fulfilled) from stock.
|
sale order line will be completely fulfilled (or has been fulfilled) from stock.
|
||||||
|
|
@ -62,8 +88,7 @@ class SaleOrderLine(models.Model):
|
||||||
non_product_lines.margin_percent_actual = 0.0
|
non_product_lines.margin_percent_actual = 0.0
|
||||||
for line in self - non_product_lines:
|
for line in self - non_product_lines:
|
||||||
stock_missing = line._determine_missing_stock()
|
stock_missing = line._determine_missing_stock()
|
||||||
if float_is_zero(stock_missing,
|
if float_is_zero(stock_missing, precision_rounding=line.product_uom.rounding):
|
||||||
precision_rounding=line.product_uom.rounding):
|
|
||||||
# everything is coming from stock, use inventory valuation
|
# everything is coming from stock, use inventory valuation
|
||||||
line.purchase_price_actual = line.purchase_price
|
line.purchase_price_actual = line.purchase_price
|
||||||
elif float_compare(line.product_uom_qty, stock_missing,
|
elif float_compare(line.product_uom_qty, stock_missing,
|
||||||
|
|
@ -79,8 +104,7 @@ class SaleOrderLine(models.Model):
|
||||||
/ line.product_uom_qty
|
/ line.product_uom_qty
|
||||||
line.margin_actual = line.price_subtotal - (
|
line.margin_actual = line.price_subtotal - (
|
||||||
line.purchase_price_actual * line.product_uom_qty)
|
line.purchase_price_actual * line.product_uom_qty)
|
||||||
line.margin_percent_actual = line.price_subtotal \
|
line.margin_percent_actual = line.price_subtotal and line.margin_actual / line.price_subtotal
|
||||||
and line.margin_actual / line.price_subtotal
|
|
||||||
|
|
||||||
def _determine_missing_stock(self) -> float:
|
def _determine_missing_stock(self) -> float:
|
||||||
""" Compute how much stock is missing to meet an order line's demand. In the
|
""" Compute how much stock is missing to meet an order line's demand. In the
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue