Skip to content

Commit

Permalink
[ADD] carpenter: Adding the module
Browse files Browse the repository at this point in the history
Added a new XML template for carpentry project quotations in Odoo.
The template provides a detailed structure for custom carpentry projects,
including project overview, material requirements, labor breakdown, and
estimated costs. It enhances user experience by automating material
calculations based on project dimensions and allows for a simplified or
detailed quotation view. The template is designed to streamline project
management, offering automatic task and project creation upon sale of
specific products, and supports flexible margin adjustments. Added the
possibility to hide SO lines to the user.

task-4243565
  • Loading branch information
jaeschwa committed Nov 8, 2024
1 parent 75b0555 commit 46524b0
Show file tree
Hide file tree
Showing 39 changed files with 1,962 additions and 0 deletions.
66 changes: 66 additions & 0 deletions carpenter/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
'name': 'Carpenter',
'version': '1.0',
'category': 'Retail',
'description': """
""",
'depends': [
'base_automation',
'contacts',
'knowledge',
'project',
'purchase',
'sale_management',
'sale_timesheet',
'stock',
'web_studio',
],
'data': [
'data/res_config_settings.xml',
'data/ir_model_fields.xml',
'data/report_view.xml',
'data/ir_actions_report.xml',
'data/mail_template.xml',
'data/ir_actions_server.xml',
'data/ir_ui_view.xml',
'data/base_automation.xml',
'data/ir_attachment_pre.xml',
'data/project_task_type.xml',
'data/project_tags.xml',
'data/project_project.xml',
'data/project_task.xml',
'data/product_product.xml',
'data/sale_order_spreadsheet.xml',
'data/sale_order_template.xml',
'data/sale_order_template_line.xml',
'data/knowledge_cover.xml',
'data/knowledge_article.xml',
'data/knowledge_article_favorite.xml',
'data/mail_message.xml',
'data/knowledge_tour.xml',
],
'demo': [
'demo/res_partner.xml',
'demo/res_user.xml',
'demo/product_supplierinfo.xml',
'demo/sale_order.xml',
'demo/sale_order_line.xml',
'demo/sale_order_confirm.xml',
'demo/purchase_order.xml',
'demo/purchase_order_line.xml',
'demo/purchase_order_confirm.xml',
],
'license': 'OPL-1',
'assets': {
'web.assets_backend': [
'carpenter/static/src/js/my_tour.js',
]
},
'author': 'Odoo S.A.',
"cloc_exclude": [
"data/knowledge_article.xml",
"data/ir_ui_view.xml",
"static/src/js/my_tour.js",
],
'images': ['images/main.png'],
}
9 changes: 9 additions & 0 deletions carpenter/data/base_automation.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version='1.0' encoding='UTF-8'?>
<odoo>
<record id="modify_portal_sale_order" model="base.automation">
<field name="model_id" ref="base.model_res_config_settings"/>
<field name="action_server_ids" eval="[(6, 0, [ref('replace_portal')])]"/>
<field name="trigger">on_create_or_write</field>
<field name="name">Modify Portal</field>
</record>
</odoo>
16 changes: 16 additions & 0 deletions carpenter/data/ir_actions_report.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version='1.0' encoding='UTF-8'?>
<odoo>
<record id="simplified_sale_report" model="ir.actions.report">
<field name="binding_model_id" ref="sale.model_sale_order"/>
<field name="model">sale.order</field>
<field name="name">Simplified Report</field>
<field name="report_name">carpenter.simplified_sales_order</field>
</record>
<record id="simplified_invoice_report" model="ir.actions.report">
<field name="binding_model_id" ref="account.model_account_move"/>
<field name="model">account.move</field>
<field name="name">Simplified Report</field>
<field name="report_name">carpenter.simplified_invoice</field>
<field name="is_invoice_report">True</field>
</record>
</odoo>
39 changes: 39 additions & 0 deletions carpenter/data/ir_actions_server.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version='1.0' encoding='UTF-8'?>
<odoo>
<record id="carpenter.replace_so_email" model="ir.actions.server">
<field name="binding_model_id" ref="sale.model_sale_order"/>
<field name="model_id" ref="sale.model_sale_order"/>
<field name="state">code</field>
<field name="name">Execute Code</field>
<field name="code">
<![CDATA[
action = record.action_quotation_send()
action['context']['default_template_id'] = env.ref("carpenter.mail_template_24").id
]]>
</field>
</record>
<!-- <record id="carpenter.replace_invoice_email" model="ir.actions.server" forcecreate="1">
<field name="binding_model_id" ref="account.model_account_move"/>
<field name="code"><![CDATA[action = record.action_invoice_sent()
action['context']['default_pdf_report_id'] = env.ref('carpenter.simplified_invoice_report').id]]></field>
<field name="model_id" ref="account.model_account_move"/>
<field name="state">code</field>
<field name="name">Replace</field>
</record> -->
<record id="replace_portal" model="ir.actions.server">
<field name="code">
<![CDATA[
view = env.ref('carpenter.portal_sale_view')
view.write({'active': record.x_simplify_so})
view = env.ref('carpenter.portal_sale_view_2')
view.write({'active': record.x_simplify_so})
view = env.ref('sale_stock.sale_order_portal_content_inherit_sale_stock')
view.write({'active': not record.x_simplify_so})
]]>
</field>
<field name="model_id" ref="base.model_res_config_settings"/>
<field name="state">code</field>
<field name="name">Execute Code</field>
<field name="usage">base_automation</field>
</record>
</odoo>
7 changes: 7 additions & 0 deletions carpenter/data/ir_attachment_pre.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<odoo noupdate="1">
<record id="ir_attachment_210" model="ir.attachment">
<field name="name">unsplash_iZgQKxuMRHc_.jpg</field>
<field name="datas" type="base64" file="carpenter/static/src/binary/ir_attachment/240-cover.jpg"/>
</record>
</odoo>
31 changes: 31 additions & 0 deletions carpenter/data/ir_model_fields.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version='1.0' encoding='UTF-8'?>
<odoo>
<record id="x_studio_unit_cost" model="ir.model.fields">
<field name="ttype">float</field>
<field name="related">product_id.standard_price</field>
<field name="field_description">Unit Cost</field>
<field name="model_id" ref="sale.model_sale_order_line"/>
<field name="name">x_studio_unit_cost</field>
<field name="on_delete" eval="False"/>
<field name="readonly" eval="True"/>
<field name="store" eval="False"/>
</record>
<record id="x_simplify_so" model="ir.model.fields">
<field name="ttype">boolean</field>
<field name="copied" eval="True"/>
<field name="field_description">Simplified SO</field>
<field name="model_id" ref="base.model_res_config_settings"/>
<field name="name">x_simplify_so</field>
<field name="on_delete" eval="False"/>
</record>

<record id="x_report" model="ir.model.fields">
<field name="ttype">many2one</field>
<field name="related">invoice_template_pdf_report_id</field>
<field name="field_description">Report</field>
<field name="model_id" ref="base.model_res_partner"/>
<field name="name">x_report</field>
<field name="relation">ir.actions.report</field>
<field name="store" eval="True"/>
</record>
</odoo>
144 changes: 144 additions & 0 deletions carpenter/data/ir_ui_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<?xml version='1.0' encoding='UTF-8'?>
<odoo>
<record id="sale_res_config_settings_inherit_view" model="ir.ui.view">
<field name="name">res.config.settings.inherit.sale.view</field>
<field name="model">res.config.settings</field>
<field name="mode">extension</field>
<field name="active" eval="True"/>
<field name="inherit_id" ref="sale.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//block[@name='quotation_order_setting_container']" position="inside">
<div class="col-12 col-lg-6 o_setting_box" id="x_simplify_so ">
<div class="o_setting_left_pane">
<field name="x_simplify_so"/>
</div>
<div class="o_setting_right_pane">
<label for="x_simplify_so" string="Simplified Sales Order"/>
<div class="text-muted mb16">
Simplified Sales Order
</div>
</div>
</div>
</xpath>
</field>
</record>
<record id="contact_report_default" model="ir.ui.view">
<field name="arch" type="xml">
<data>
<xpath expr="//field[@name='category_id']" position="after">
<field name="x_report" domain="[(&quot;binding_model_id&quot;, &quot;in&quot;, [471])]"/>
</xpath>
</data>
</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="mode">extension</field>
<field name="model">res.partner</field>
<field name="active" eval="True"/>
<field name="name">Odoo Studio: res.partner.form customization</field>
<field name="priority">360</field>
<field name="type">form</field>
</record>
<record id="sale_order_custom_view" model="ir.ui.view" >
<field name="arch" type="xml">
<data>
<xpath expr="//form[1]/header[1]/field[@name='state']" position="after">
<button string="Send Simplified Email" name="carpenter.replace_so_email" type="action"/>
</xpath>
<xpath expr="//form[1]/sheet[1]/notebook[1]/page[@name='order_lines']/field[@name='order_line']/list[1]/field[@name='product_uom']" position="after">
<field optional="show" name="x_studio_unit_cost"/>
<attribute name="column_invisible">True</attribute>
</xpath>
<xpath expr="//form[1]/sheet[1]/notebook[1]/page[@name='order_lines']/field[@name='order_line']/list[1]/field[@name='discount']" position="attributes">
<attribute name="column_invisible">True</attribute>
</xpath>
</data>
</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="mode">extension</field>
<field name="model">sale.order</field>
<field name="name">Odoo Studio: sale.order.form customization</field>
<field name="priority">160</field>
<field name="type">form</field>
<field name="active" eval="True"/>
</record>
<record id="portal_sale_view_2" model="ir.ui.view">
<field name="name">portal_sale_view.customization2</field>
<field name="inherit_id" ref="sale.sale_order_portal_template"/>
<field name="mode">extension</field>
<field name="model"></field>
<field name="active" eval="False"/>
<field name="priority">160</field>
<field name="type">qweb</field>
<field name="arch" type="xml">
<xpath expr="//div[hasclass('o_download_pdf', 'd-flex', 'gap-2', 'flex-lg-column', 'flex-xl-row', 'flex-wrap')]" position="replace"/>
</field>
</record>
<record id="portal_sale_view" model="ir.ui.view">
<field name="name">portal_sale_view.customization</field>
<field name="inherit_id" ref="sale.sale_order_portal_content"/>
<field name="mode">extension</field>
<field name="model"></field>
<field name="active" eval="False"/>
<field name="priority">160</field>
<field name="type">qweb</field>
<field name="arch" type="xml">
<data inherit_id="sale.sale_order_portal_content" name="Default">
<xpath expr="//table[@id='sales_order_table']" position="replace">
<table t-att-data-order-id="sale_order.id" t-att-data-token="sale_order.access_token" class="table table-sm" id="sales_order_table">
<thead>
<tr>
<th class="text-start">Product</th>
<th class="text-end text-nowrap">Total Amount</th>
</tr>
</thead>
<tbody class="sale_tbody">
<t t-set="current_subtotal" t-value="0"/>
<t t-set="lines_to_report" t-value="sale_order._get_order_lines_to_report()"/>
<t t-set="has_section" t-value="any(line.display_type == 'line_section' or line.product_type == 'combo' for line in lines_to_report)"/>

<t t-if="has_section">
<t t-foreach="lines_to_report" t-as="line">
<t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal"/>
<t t-if="line.display_type == 'line_section' or line.product_type == 'combo'">
<tr>
<td colspan="99">
<span t-field="line.name"/>
</td>
<t t-set="current_section" t-value="line"/>
<t t-set="current_subtotal" t-value="0"/>
</tr>
</t>
<t t-if="current_section and (line_last or lines_to_report[line_index+1].display_type == 'line_section')">
<tr class="is-subtotal text-end">
<td colspan="99">
<strong class="mr16">Subtotal</strong>
<span t-out="current_subtotal" t-options="{'widget': 'monetary', 'display_currency': sale_order.currency_id}"/>
</td>
</tr>
<t t-set="current_section" t-value="None"/>
</t>
</t>
</t>

<t t-else="">
<tr>
<td colspan="99">
<strong>Project: </strong>
<span t-field="sale_order.name"/>
</td>
</tr>
<tr class="is-subtotal text-end">
<td colspan="99">
<strong class="mr16">Total</strong>
<span t-out="sale_order.amount_total" t-options="{'widget': 'monetary', 'display_currency': sale_order.currency_id}"/>
</td>
</tr>
</t>
</tbody>
</table>
</xpath>

</data>
</field>
</record>
</odoo>
Loading

0 comments on commit 46524b0

Please sign in to comment.