Skip to content

Commit

Permalink
[REF] repair: multi company
Browse files Browse the repository at this point in the history
task-2081645
  • Loading branch information
sle-odoo committed Oct 15, 2019
1 parent 5f082f8 commit dfa5390
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 58 deletions.
1 change: 1 addition & 0 deletions addons/repair/data/ir_sequence_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<field name="code">repair.order</field>
<field name="prefix">RMA/</field>
<field name="padding">5</field>
<field name="company_id" eval="False"/>
</record>
</data>
</odoo>
6 changes: 6 additions & 0 deletions addons/repair/data/repair_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@
'price_unit': 50.0,
'state': 'draft',
'type': 'add',
'company_id': obj().env.ref('base.main_company').id,
})]"/>
<field name="fees_lines" model="repair.fee" eval="[(5, 0, 0), (0, 0, {
'name': obj().env.ref('repair.product_service_order_repair').get_product_multiline_description_sale(),
'product_id': obj().env.ref('repair.product_service_order_repair').id,
'product_uom_qty': 1.0,
'product_uom': obj().env.ref('uom.product_uom_unit').id,
'company_id': obj().env.ref('base.main_company').id,
'price_unit': 50.0,
})]"/>
<field name="partner_id" ref="base.res_partner_12"/>
Expand All @@ -57,13 +59,15 @@
'product_uom_qty': 1.0,
'state': 'draft',
'type': 'add',
'company_id': obj().env.ref('base.main_company').id,
})]"/>
<field name="fees_lines" model="repair.fee" eval="[(5, 0, 0), (0, 0, {
'name': obj().env.ref('repair.product_service_order_repair').get_product_multiline_description_sale(),
'product_id': obj().env.ref('repair.product_service_order_repair').id,
'product_uom_qty': 1.0,
'product_uom': obj().env.ref('uom.product_uom_unit').id,
'price_unit': 50.0,
'company_id': obj().env.ref('base.main_company').id,
})]"/>
<field name="partner_id" ref="base.res_partner_12"/>
</record>
Expand All @@ -87,13 +91,15 @@
'product_uom_qty': 1.0,
'state': 'draft',
'type': 'add',
'company_id': obj().env.ref('base.main_company').id,
})]"/>
<field name="fees_lines" model="repair.fee" eval="[(5, 0, 0), (0, 0, {
'name': obj().env.ref('repair.product_service_order_repair').get_product_multiline_description_sale(),
'product_id': obj().env.ref('repair.product_service_order_repair').id,
'product_uom_qty': 1.0,
'product_uom': obj().env.ref('uom.product_uom_unit').id,
'price_unit': 50.0,
'company_id': obj().env.ref('base.main_company').id,
})]"/>
<field name="partner_id" ref="base.res_partner_12"/>
</record>
Expand Down
110 changes: 70 additions & 40 deletions addons/repair/models/repair.py

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions addons/repair/models/stock_traceability.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import models, api


class MrpStockReport(models.TransientModel):
_inherit = 'stock.traceability.report'

Expand All @@ -20,3 +23,4 @@ def _get_linked_move_lines(self, move_line):
if not is_used:
is_used = move_line.move_id.repair_id and move_line.produce_line_ids
return move_lines, is_used

20 changes: 16 additions & 4 deletions addons/repair/security/repair_security.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,24 @@
<odoo>
<data noupdate="1">

<!-- Multi -->
<record model="ir.rule" id="repair_rule">
<field name="name">repair multi-company</field>
<!-- Multicompay rules-->
<record model="ir.rule" id="repair_order_rule">
<field name="name">repair order multi-company</field>
<field name="model_id" search="[('model','=','repair.order')]" model="ir.model"/>
<field name="global" eval="True"/>
<field name="domain_force">['|',('company_id', 'in', company_ids),('company_id','=',False)]</field>
<field name="domain_force">[('company_id', 'in', company_ids)]</field>
</record>
<record model="ir.rule" id="repair_line_rule">
<field name="name">repair line multi-company</field>
<field name="model_id" search="[('model','=','repair.line')]" model="ir.model"/>
<field name="global" eval="True"/>
<field name="domain_force">[('company_id', 'in', company_ids)]</field>
</record>
<record model="ir.rule" id="repair_fee_rule">
<field name="name">repair fee multi-company</field>
<field name="model_id" search="[('model','=','repair.fee')]" model="ir.model"/>
<field name="global" eval="True"/>
<field name="domain_force">[('company_id', 'in', company_ids)]</field>
</record>

</data>
Expand Down
2 changes: 2 additions & 0 deletions addons/repair/tests/test_repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def _create_simple_operation(self, repair_id=False, qty=0.0, price_unit=0.0):
'repair_id': repair_id,
'location_id': self.env.ref('stock.stock_location_stock').id,
'location_dest_id': product_to_add.property_stock_production.id,
'company_id': self.env.company.id,
})

def _create_simple_fee(self, repair_id=False, qty=0.0, price_unit=0.0):
Expand All @@ -71,6 +72,7 @@ def _create_simple_fee(self, repair_id=False, qty=0.0, price_unit=0.0):
'product_uom': product_service.uom_id.id,
'price_unit': price_unit,
'repair_id': repair_id,
'company_id': self.env.company.id,
})

def test_00_repair_afterinv(self):
Expand Down
32 changes: 18 additions & 14 deletions addons/repair/views/repair_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@
<group>
<group>
<field name="tracking" invisible="1" attrs="{'readonly': 1}"/>
<field name="product_id" domain="[('type', 'in', ['product', 'consu'])]"/>
<field name="product_id" />
<field name="product_uom_category_id" invisible="1"/>
<label for="product_qty"/>
<div class="o_row">
<field name="product_qty"/>
<field name="product_uom" groups="uom.group_uom"/>
</div>
<field name="lot_id" domain="[('product_id', '=', product_id)]" context="{'default_product_id': product_id}" groups="stock.group_production_lot" attrs="{'required':[('tracking', 'in', ['serial', 'lot'])], 'invisible': [('tracking', 'not in', ['serial', 'lot'])], 'readonly': [('state', '=', 'done')]}"/>
<field name="lot_id" context="{'default_product_id': product_id, 'default_company_id': company_id}" groups="stock.group_production_lot" attrs="{'required':[('tracking', 'in', ['serial', 'lot'])], 'invisible': [('tracking', 'not in', ['serial', 'lot'])], 'readonly': [('state', '=', 'done')]}"/>
<field name="partner_id" widget="res_partner_many2one" attrs="{'required':[('invoice_method','!=','none')]}" context="{'show_vat': True}"/>
<field name="address_id" groups="sale.group_delivery_invoice_address"/>
<field name="user_id"/>
Expand All @@ -87,10 +87,11 @@
</group>
<notebook>
<page string="Parts">
<field name="operations" context="{'default_product_uom_qty': product_qty}">
<field name="operations" context="{'default_product_uom_qty': product_qty, 'default_company_id': company_id}">
<form string="Operations">
<group>
<group>
<field name="company_id" invisible="1" force_save="1"/>
<field name="type"/>
<field name="product_id"/>
<field name="name"/>
Expand All @@ -101,12 +102,12 @@
<field name="product_uom" groups="uom.group_uom"/>
</div>
<field name="price_unit"/>
<field name="tax_id" widget="many2many_tags" domain="[('type_tax_use','=','sale')]"/>
<field name="tax_id" widget="many2many_tags"/>
<field name="invoiced" invisible="1"/>
<field name="price_subtotal" widget="monetary" invisible="1"/>
</group>
<group>
<field name="lot_id" domain="[('product_id', '=', product_id)]" context="{'default_product_id': product_id}" groups="stock.group_production_lot"/>
<field name="lot_id" context="{'default_product_id': product_id, 'default_company_id': company_id}" groups="stock.group_production_lot"/>
<field name="location_id" options="{'no_create': True}" groups="stock.group_stock_multi_locations"/>
<field name="location_dest_id" options="{'no_create': True}" groups="stock.group_stock_multi_locations"/>
</group>
Expand All @@ -117,17 +118,18 @@
</group>
</form>
<tree string="Operations" editable="bottom">
<field name="company_id" invisible="1" force_save="1"/>
<field name="type"/>
<field name="product_id" domain="[('type', '!=', 'service')]"/>
<field name="product_id"/>
<field name='name' optional="show"/>
<field name="product_uom_category_id" invisible="1"/>
<field name="lot_id" domain="[('product_id', '=', product_id)]" context="{'default_product_id': product_id}" groups="stock.group_production_lot"/>
<field name="lot_id" context="{'default_product_id': product_id, 'default_company_id': company_id}" groups="stock.group_production_lot"/>
<field name="location_id" options="{'no_create': True}" groups="stock.group_stock_multi_locations" optional="show"/>
<field name="location_dest_id" options="{'no_create': True}" groups="stock.group_stock_multi_locations" optional="show"/>
<field name="product_uom_qty" string="Quantity"/>
<field name="product_uom" string="UoM" groups="uom.group_uom" optional="show"/>
<field name="price_unit"/>
<field name="tax_id" widget="many2many_tags" domain="[('type_tax_use','=','sale')]" optional="show"/>
<field name="tax_id" widget="many2many_tags" optional="show"/>
<field name="price_subtotal" widget="monetary"/>
</tree>
</field>
Expand All @@ -144,11 +146,11 @@
<div class="oe_clear"/>
</page>
<page string="Operations">
<!-- <field name="invoice_id"/> -->
<field name="fees_lines">
<field name="fees_lines" context="{'default_company_id': company_id}">
<form string="Fees">
<group>
<field name="product_id" domain="[('type','=','service')]" required="True"/>
<field name="company_id" invisible="1" force_save="1"/>
<field name="product_id" required="True"/>
<field name="name"/>
<field name="product_uom_category_id" invisible="1"/>
<label for="product_uom_qty"/>
Expand All @@ -157,18 +159,19 @@
<field name="product_uom" groups="uom.group_uom"/>
</div>
<field name="price_unit"/>
<field widget="many2many_tags" name="tax_id" domain="[('type_tax_use','=','sale')]"/>
<field widget="many2many_tags" name="tax_id"/>
<field name="price_subtotal" widget="monetary" invisible="1"/>
</group>
</form>
<tree string="Fees" editable="bottom">
<field name="product_id" domain="[('type','=','service')]" required="True"/>
<field name="company_id" invisible="1" force_save="1"/>
<field name="product_id" required="True"/>
<field name='name' optional="show"/>
<field name="product_uom_qty" string="Quantity"/>
<field name="product_uom_category_id" invisible="1"/>
<field name="product_uom" string="Unit of Measure" groups="uom.group_uom" optional="show"/>
<field name="price_unit"/>
<field name="tax_id" domain="[('type_tax_use', '=', 'sale')]" widget="many2many_tags" optional="show"/>
<field name="tax_id" widget="many2many_tags" optional="show"/>
<field name="price_subtotal" widget="monetary"/>
</tree>
</field>
Expand Down Expand Up @@ -205,6 +208,7 @@
<field name="model">repair.order</field>
<field name="arch" type="xml">
<kanban class="o_kanban_mobile">
<field name="company_id" invisible="1"/>
<field name="name" />
<field name="product_id" />
<field name="partner_id"/>
Expand Down

0 comments on commit dfa5390

Please sign in to comment.