Merge pull request #19 from bakeupboys/71-16.0-make_sale_order_batch_company_dependend
[imp] add multi company ability
This commit is contained in:
commit
8f1547a5b3
7 changed files with 26 additions and 8 deletions
|
|
@ -35,6 +35,7 @@ Changelog
|
|||
=========
|
||||
|
||||
:0.0.1: Initial module.
|
||||
:1.0.0: Add Multi Company ability
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
"views/sale_order_views.xml",
|
||||
"views/sale_menus.xml",
|
||||
"security/ir.model.access.csv",
|
||||
"security/ir_rules.xml",
|
||||
],
|
||||
"license": "LGPL-3",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,13 +5,16 @@ from odoo.exceptions import UserError
|
|||
class SaleOrder(models.Model):
|
||||
_inherit = "sale.order"
|
||||
|
||||
batch_id = fields.Many2one("sale.order.batch", copy=False)
|
||||
batch_id = fields.Many2one("sale.order.batch", copy=False, check_company=True)
|
||||
|
||||
def action_add_to_batch(self):
|
||||
"""
|
||||
TODO: Add Wizard to choose between batches if more than one existis. Picking the first one for now.
|
||||
"""
|
||||
batch = self.env["sale.order.batch"].search([("state", "=", "open")], limit=1)
|
||||
self = self.with_company(self.company_id)
|
||||
batch = self.env["sale.order.batch"].search(
|
||||
[("state", "=", "open"), ("company_id", "=", self.company_id.id)], limit=1
|
||||
)
|
||||
if not batch:
|
||||
batch = self.env["sale.order.batch"].create({})
|
||||
for sale_order in self:
|
||||
|
|
|
|||
|
|
@ -11,11 +11,7 @@ class SaleOrderBatch(models.Model):
|
|||
_description = "Sale Order Batch"
|
||||
_inherit = "mail.thread"
|
||||
_order = "date_order desc, id desc"
|
||||
|
||||
# TODO: add company_id to sale order batch
|
||||
# company_id = fields.Many2one(
|
||||
# related='order_id.company_id',
|
||||
# store=True, index=True, precompute=True)
|
||||
_check_company_auto = True
|
||||
|
||||
name = fields.Char(
|
||||
string="Order Batch Reference",
|
||||
|
|
@ -25,6 +21,9 @@ class SaleOrderBatch(models.Model):
|
|||
index="trigram",
|
||||
default=lambda self: _("New"),
|
||||
)
|
||||
company_id = fields.Many2one(
|
||||
comodel_name="res.company", required=True, index=True, default=lambda self: self.env.company
|
||||
)
|
||||
state = fields.Selection(
|
||||
selection=[("open", "Open"), ("closed", "Closed")],
|
||||
string="Status",
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
:0.0.1: Initial module.
|
||||
:0.0.1: Initial module.
|
||||
:1.0.0: Add Multi Company ability
|
||||
11
sale_order_batch/security/ir_rules.xml
Normal file
11
sale_order_batch/security/ir_rules.xml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo noupdate="1">
|
||||
|
||||
<!-- Multi - Company Rules -->
|
||||
<record id="sale_order_batch_comp_rule" model="ir.rule">
|
||||
<field name="name">Sales Order Batch multi-company</field>
|
||||
<field name="model_id" ref="model_sale_order_batch"/>
|
||||
<field name="domain_force">[('company_id', 'in', company_ids)]</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
|
@ -394,6 +394,8 @@ anymore as log as they are part of a batch. Only Sale Orders in state Qutotation
|
|||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">0.0.1:</th><td class="field-body">Initial module.</td>
|
||||
</tr>
|
||||
<tr class="field"><th class="field-name">1.0.0:</th><td class="field-body">Add Multi Company ability</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue