summaryrefslogtreecommitdiff
path: root/addons/l10n_in_purchase
diff options
context:
space:
mode:
authorJigar Vaghela <jva@odoo.com>2019-09-26 07:13:26 +0000
committerJigar Vaghela <jva@odoo.com>2019-09-27 11:39:39 +0000
commitea9e8a37d6f7bc58ee5d323830310173c33ed20d (patch)
tree46c567023681b2765d1ac299bca619bab14d86a3 /addons/l10n_in_purchase
parent85eeaccf065b151dbc9f0e1a24f1b4f674dec6cc (diff)
[IMP] l10n_in*: multi GSTIN Using journal
======= Purpose ======= government rule that "GST registration should be obtained by a taxable person under GST in each of the State or Union Territory, from where the taxable supply of goods or services is made" So we managed this using journal User create journal and partner for other states After user can select journal in Sale order, Purchase order and warehouse ======== Solution ======== -Add a field on the journal to define the GSTIN -Add sale and purchase journal field in warehouse -On the SO/PO, add the journal field and based on the warehouse journal it set automatically fill if warehouse journal is set. task 1917619
Diffstat (limited to 'addons/l10n_in_purchase')
-rw-r--r--addons/l10n_in_purchase/__init__.py1
-rw-r--r--addons/l10n_in_purchase/__manifest__.py1
-rw-r--r--addons/l10n_in_purchase/models/__init__.py5
-rw-r--r--addons/l10n_in_purchase/models/account_move.py16
-rw-r--r--addons/l10n_in_purchase/models/purchase_order.py19
-rw-r--r--addons/l10n_in_purchase/views/purchase_order_views.xml13
6 files changed, 55 insertions, 0 deletions
diff --git a/addons/l10n_in_purchase/__init__.py b/addons/l10n_in_purchase/__init__.py
index 2903e8d9121..dc5e6b693d1 100644
--- a/addons/l10n_in_purchase/__init__.py
+++ b/addons/l10n_in_purchase/__init__.py
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
+from . import models
diff --git a/addons/l10n_in_purchase/__manifest__.py b/addons/l10n_in_purchase/__manifest__.py
index 0d6e75058d9..eb5116fc954 100644
--- a/addons/l10n_in_purchase/__manifest__.py
+++ b/addons/l10n_in_purchase/__manifest__.py
@@ -12,6 +12,7 @@
],
'data': [
'views/report_purchase_order.xml',
+ 'views/purchase_order_views.xml',
],
'installable': True,
'application': False,
diff --git a/addons/l10n_in_purchase/models/__init__.py b/addons/l10n_in_purchase/models/__init__.py
new file mode 100644
index 00000000000..476326ad60b
--- /dev/null
+++ b/addons/l10n_in_purchase/models/__init__.py
@@ -0,0 +1,5 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from . import purchase_order
+from . import account_move
diff --git a/addons/l10n_in_purchase/models/account_move.py b/addons/l10n_in_purchase/models/account_move.py
new file mode 100644
index 00000000000..4587df067e7
--- /dev/null
+++ b/addons/l10n_in_purchase/models/account_move.py
@@ -0,0 +1,16 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import api, models
+
+
+class AccountMove(models.Model):
+ _inherit = 'account.move'
+
+ @api.onchange('purchase_vendor_bill_id', 'purchase_id')
+ def _onchange_purchase_auto_complete(self):
+ if self.purchase_vendor_bill_id.purchase_order_id or self.purchase_id:
+ journal_id = self.purchase_vendor_bill_id.purchase_order_id.l10n_in_journal_id or self.purchase_id.l10n_in_journal_id
+ if journal_id:
+ self.journal_id = journal_id
+ return super()._onchange_purchase_auto_complete()
diff --git a/addons/l10n_in_purchase/models/purchase_order.py b/addons/l10n_in_purchase/models/purchase_order.py
new file mode 100644
index 00000000000..9cdecfb3064
--- /dev/null
+++ b/addons/l10n_in_purchase/models/purchase_order.py
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import api, fields, models
+
+
+class PurchaseOrder(models.Model):
+ _inherit = "purchase.order"
+
+ l10n_in_journal_id = fields.Many2one('account.journal', string="Journal", \
+ states={'posted': [('readonly', True)]}, domain="[('type','=', 'purchase')]")
+
+ @api.onchange('company_id')
+ def l10n_in_onchange_company_id(self):
+ domain = [('company_id', '=', self.company_id.id), ('type', '=', 'purchase')]
+
+ journal = self.env['account.journal'].search(domain, limit=1)
+ if journal:
+ self.l10n_in_journal_id = journal.id
diff --git a/addons/l10n_in_purchase/views/purchase_order_views.xml b/addons/l10n_in_purchase/views/purchase_order_views.xml
new file mode 100644
index 00000000000..f60d9dae8f9
--- /dev/null
+++ b/addons/l10n_in_purchase/views/purchase_order_views.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<odoo>
+ <record id="view_purchase_order_form_inherit_l10n_in_purchase" model="ir.ui.view">
+ <field name="name">purchase.order.form.inherit.l10n.in.purchase</field>
+ <field name="model">purchase.order</field>
+ <field name="inherit_id" ref="purchase.purchase_order_form"/>
+ <field name="arch" type="xml">
+ <xpath expr="//group[@name='other_info']//field[@name='user_id']" position="after">
+ <field name="l10n_in_journal_id" domain="[('company_id', '=', company_id), ('type','=','purchase')]" options="{'no_create': True}"/>
+ </xpath>
+ </field>
+ </record>
+</odoo>