Skip to content

Master construction wi bom dev#18

Draft
trcazier wants to merge 13 commits into
master-construction-wi-bom-poc-trcazfrom
master-construction-wi-bom-dev
Draft

Master construction wi bom dev#18
trcazier wants to merge 13 commits into
master-construction-wi-bom-poc-trcazfrom
master-construction-wi-bom-dev

Conversation

@trcazier

@trcazier trcazier commented Jul 1, 2026

Copy link
Copy Markdown

No description provided.

@trcazier trcazier force-pushed the master-construction-wi-bom-dev branch 3 times, most recently from 586d3a2 to 25ea2db Compare July 2, 2026 13:47

@vava-odoo vava-odoo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I skipped wbs for now

@@ -0,0 +1,12 @@
<?xml version='1.0' encoding='UTF-8'?>
<odoo>
<record id="access_construction_developer_x_cost_nature_analysis_report" model="ir.model.access">

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<record id="access_construction_developer_x_cost_nature_analysis_report" model="ir.model.access">
<record id="access_construction_developer_x_cost_nature_analysis_report" model="ir.access">

<record model="ir.model.fields" id="field_x_cost_nature_analysis_report_x_cost_nature">
<field name="model_id" ref="model_x_cost_nature_analysis_report"/>
<field name="ttype">selection</field>
<field name="name">x_cost_nature</field>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not a related to the category's value?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we fetch everything using the SQL query, I don't know if that's possible/good practice?

Comment on lines +118 to +167
<record model="ir.model.fields" id="field_sale_order_line_x_cost_nature">
<field name="name">x_cost_nature</field>
<field name="field_description">Cost Nature</field>
<field name="ttype">selection</field>
<field name="related">product_id.product_tmpl_id.categ_id.x_cost_nature</field>
<field name="model_id" ref="sale.model_sale_order_line"/>
<field name="store" eval="True"/>
</record>
<record model="ir.model.fields" id="field_mrp_bom_line_x_cost_nature">
<field name="name">x_cost_nature</field>
<field name="field_description">Cost Nature</field>
<field name="ttype">selection</field>
<field name="related">product_tmpl_id.categ_id.x_cost_nature</field>
<field name="model_id" ref="mrp.model_mrp_bom_line"/>
<field name="store" eval="True"/>
</record>
<record model="ir.model.fields" id="field_mrp_bom_line_x_category_id">
<field name="name">x_category_id</field>
<field name="field_description">Category</field>
<field name="ttype">many2one</field>
<field name="related">product_tmpl_id.categ_id</field>
<field name="model_id" ref="mrp.model_mrp_bom_line"/>
<field name="relation">product.category</field>
<field name="store" eval="True"/>
</record>
<record model="ir.model.fields" id="field_x_sale_order_line_x_category_id">
<field name="name">x_category_id</field>
<field name="field_description">Category</field>
<field name="ttype">many2one</field>
<field name="related">product_id.product_tmpl_id.categ_id</field>
<field name="model_id" ref="sale.model_sale_order_line"/>
<field name="relation">product.category</field>
<field name="store" eval="True"/>
</record>
<record model="ir.model.fields" id="field_mrp_bom_line_x_unit_price">
<field name="name">x_unit_price</field>
<field name="field_description">Unit Price</field>
<field name="ttype">float</field>
<field name="related">product_tmpl_id.list_price</field>
<field name="model_id" ref="mrp.model_mrp_bom_line"/>
<field name="store" eval="True"/>
</record>
<record model="ir.model.fields" id="field_mrp_bom_line_x_unit_cost">
<field name="name">x_unit_cost</field>
<field name="field_description">Unit Cost</field>
<field name="ttype">float</field>
<field name="related">product_tmpl_id.standard_price</field>
<field name="model_id" ref="mrp.model_mrp_bom_line"/>
<field name="store" eval="True"/>
</record>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are those fields only defined to reduce the query?


# action called from a project: fetch the records from the project
# action called from a sale order: passed in the context as active_ids
so_ids = (env.context.get('active_ids') if not (project_id := env.context.get('project_id')) else env['sale.order'].search([('project_id', '=', project_id)]).ids) or [0]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the fallback mecanism a bit weird here. For example, if project_id is not provided in the context, it seems to me you'll get all sale.order linked to no project

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If project in the context: find all sale orders with that project and use them
If not project in the context: use the current active_ids so
If none of the above: use [0]

# e.g., [1, 2] becomes "(1, 2)" and [1] becomes "(1)"
so_ids_sql = tuple(so_ids) if len(so_ids) > 1 else f"({so_ids[0]})"

# Actual logic

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Comment on lines +79 to +80
<xpath expr="//group[@name='second']" position="before">
<xpath expr="//group[@name='first']" position="move"/>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move first before second? Yeah, why not?
I'd rather stick to standard here

<xpath expr="//form/sheet/div[@name='button_box']" position="inside">
<button class="oe_stat_button" type="action" name="%(action_compute_cost_nature_analysis_report)d"
icon="fa-indent"
context="{'active_ids': [id]}"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd say context is provided natively, no?

# does not work if only on_create because purchase_id does not exist yet
# does not work if purchase_id is set as trigger_field_ids
# does not work if the first 2 conditions are added to the automation domain
if p.purchase_id and p.purchase_id.x_delivery_site_id and p.location_dest_id == p.picking_type_id.default_location_dest_id:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if p.purchase_id and p.purchase_id.x_delivery_site_id and p.location_dest_id == p.picking_type_id.default_location_dest_id:
if p.purchase_id.x_delivery_site_id and p.location_dest_id == p.picking_type_id.default_location_dest_id:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and so the user can't set the default location as destination? That's weird

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only if x_delivery_site_id is set, a field that is shown only if which only happens when x_show_delivery_site, which is a related of x_select_dest_on_po which is a boolean on the picking type which allows the user to pick the delivery on the PO, which we use here. So if the user wants to deliver it to the default location, they can select it on the PO and this will work

@trcazier trcazier force-pushed the master-construction-wi-bom-dev branch from e3f2b80 to e6c1f83 Compare July 7, 2026 11:04
@trcazier trcazier force-pushed the master-construction-wi-bom-poc-trcaz branch from 00cbcb5 to 48c1406 Compare July 7, 2026 11:11
@trcazier trcazier force-pushed the master-construction-wi-bom-dev branch from e6c1f83 to 4a9707b Compare July 7, 2026 11:12
@trcazier trcazier force-pushed the master-construction-wi-bom-dev branch from da42bb5 to cdff1b4 Compare July 9, 2026 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants