Skip to content

Commit

Permalink
[UPD] ssi_purchase
Browse files Browse the repository at this point in the history
  • Loading branch information
Miftahussalam committed Nov 5, 2023
1 parent 630bedb commit aa97b1d
Show file tree
Hide file tree
Showing 10 changed files with 165 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ssi_purchase/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Copyright 2023 OpenSynergy Indonesia
# Copyright 2023 PT. Simetri Sinergi Indonesia
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import (
models
)
5 changes: 4 additions & 1 deletion ssi_purchase/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
{
"name": "Purchase",
"version": "14.0.1.0.0",
"version": "14.0.2.0.0",
"website": "https://simetri-sinergi.id",
"author": "PT. Simetri Sinergi Indonesia, OpenSynergy Indonesia",
"license": "LGPL-3",
Expand All @@ -13,12 +13,15 @@
"purchase",
],
"data": [
"security/ir.model.access.csv",
"security/ir_module_category_data.xml",
"security/res_group_data.xml",
"security/ir_rule_data.xml",
"data/purchase_order_type.xml",
"views/res_partner_views.xml",
"views/purchase_order_views.xml",
"views/product_product_views.xml",
"views/purchase_order_type_views.xml",
],
"demo": [],
}
14 changes: 14 additions & 0 deletions ssi_purchase/data/purchase_order_type.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2022 OpenSynergy Indonesia
Copyright 2022 PT. Simetri Sinergi Indonesia
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<odoo>
<data noupdate="1">

<record id="purchase_order_type_normal" model="purchase_order_type">
<field name="name">Normal</field>
<field name="code">T0001</field>
</record>

</data>
</odoo>
24 changes: 24 additions & 0 deletions ssi_purchase/migrations/14.0.2.0.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2023 OpenSynergy Indonesia
# Copyright 2023 PT. Simetri Sinergi Indonesia
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
import logging


def migrate(cr, version):
if not version:
return
logger = logging.getLogger(__name__)
logger.info("Updating purchase_order...")
cr.execute(
"""
UPDATE
purchase_order po
SET
type_id = t.id
FROM purchase_order_type t
WHERE
t.code = 'T0001'
AND po.type_id IS NULL;
"""
)
logger.info("Successfully updated purchase_order tables")
8 changes: 8 additions & 0 deletions ssi_purchase/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright 2023 OpenSynergy Indonesia
# Copyright 2023 PT. Simetri Sinergi Indonesia
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import (
purchase_order_type,
purchase_order,
)
20 changes: 20 additions & 0 deletions ssi_purchase/models/purchase_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2023 OpenSynergy Indonesia
# Copyright 2023 PT. Simetri Sinergi Indonesia
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import api, fields, models, _
from odoo.exceptions import ValidationError


class PurchaseOrder(models.Model):
_inherit = 'purchase.order'

type_id = fields.Many2one(
comodel_name='purchase_order_type',
string='Type',
required=True,
readonly=True,
states={
"draft": [("readonly", False)],
},
)
15 changes: 15 additions & 0 deletions ssi_purchase/models/purchase_order_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2023 OpenSynergy Indonesia
# Copyright 2023 PT. Simetri Sinergi Indonesia
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import api, fields, models, _
from odoo.exceptions import ValidationError


class PurchaseOrderType(models.Model):
_name = "purchase_order_type"
_inherit = [
'mixin.master_data',
]
_description = "Purchase Order Type"
_field_name_string = "Purchase Order Type"
2 changes: 2 additions & 0 deletions ssi_purchase/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_purchase_order_type_all,purchase_order_type - all,model_purchase_order_type,,1,1,1,1
63 changes: 63 additions & 0 deletions ssi_purchase/views/purchase_order_type_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 OpenSynergy Indonesia
Copyright 2023 PT. Simetri Sinergi Indonesia
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0-standalone.html). -->
<odoo>

<record id="purchase_order_type_view_search" model="ir.ui.view">
<field name="name">purchase_order_type search</field>
<field name="model">purchase_order_type</field>
<field
name="inherit_id"
ref="ssi_master_data_mixin.mixin_master_data_view_search"
/>
<field name="mode">primary</field>
<field name="arch" type="xml">
<data>
</data>
</field>
</record>

<record id="purchase_order_type_view_tree" model="ir.ui.view">
<field name="name">purchase_order_type tree</field>
<field name="model">purchase_order_type</field>
<field
name="inherit_id"
ref="ssi_master_data_mixin.mixin_master_data_view_tree"
/>
<field name="mode">primary</field>
<field name="arch" type="xml">
<data />
</field>
</record>

<record id="purchase_order_type_view_form" model="ir.ui.view">
<field name="name">purchase_order_type form</field>
<field name="model">purchase_order_type</field>
<field
name="inherit_id"
ref="ssi_master_data_mixin.mixin_master_data_view_form"
/>
<field name="mode">primary</field>
<field name="arch" type="xml">
<data>
</data>
</field>
</record>

<record id="purchase_order_type_action" model="ir.actions.act_window">
<field name="name">Purchase Order Types</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">purchase_order_type</field>
<field name="view_mode">tree,form</field>
</record>

<menuitem
id="purchase_order_type_menu"
name="Purchase Order Types"
parent="purchase.menu_purchase_config"
action="purchase_order_type_action"
sequence="10"
/>

</odoo>
11 changes: 11 additions & 0 deletions ssi_purchase/views/purchase_order_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@
<field name="groups_id" eval="[(6, 0, [ref('original_purchase_group')])]" />
</record>

<record id="purchase_order_form_view_form" model="ir.ui.view">
<field name="name">purchase.order.form</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='partner_ref']" position="after">
<field name="type_id" options="{'no_open': True, 'no_create': True}"/>
</xpath>
</field>
</record>

<record id="purchase_form_action" model="ir.actions.act_window">
<field name="name">Purchase Orders</field>
<field name="type">ir.actions.act_window</field>
Expand Down

0 comments on commit aa97b1d

Please sign in to comment.