diff options
| -rwxr-xr-x | fixco_custom/__manifest__.py | 3 | ||||
| -rwxr-xr-x | fixco_custom/models/__init__.py | 4 | ||||
| -rw-r--r-- | fixco_custom/models/account_lock_date.py | 12 | ||||
| -rw-r--r-- | fixco_custom/models/account_move.py | 15 | ||||
| -rw-r--r-- | fixco_custom/models/res_company.py | 17 | ||||
| -rw-r--r-- | fixco_custom/views/account_lock_date.xml | 15 |
6 files changed, 64 insertions, 2 deletions
diff --git a/fixco_custom/__manifest__.py b/fixco_custom/__manifest__.py index ad6d178..b72622a 100755 --- a/fixco_custom/__manifest__.py +++ b/fixco_custom/__manifest__.py @@ -8,7 +8,7 @@ 'author': 'Stephan Christianus, Azka Nathan', 'website': '', 'images': ['assets/favicon.ico'], - 'depends': ['base', 'coupon', 'delivery', 'sale', 'sale_management', 'proweb_kartu_stok'], + 'depends': ['base', 'coupon', 'delivery', 'sale', 'sale_management', 'proweb_kartu_stok', 'base_accounting_kit'], 'data': [ 'security/ir.model.access.csv', 'views/res_partner.xml', @@ -57,6 +57,7 @@ 'views/account_move_line.xml', 'views/stock_inventory.xml', 'views/kartu_stock.xml', + 'views/account_lock_date.xml', ], 'demo': [], 'css': [], diff --git a/fixco_custom/models/__init__.py b/fixco_custom/models/__init__.py index 36d2553..1207010 100755 --- a/fixco_custom/models/__init__.py +++ b/fixco_custom/models/__init__.py @@ -43,4 +43,6 @@ from . import account_payment from . import stock_location from . import account_asset from . import stock_inventory -from . import kartu_stock
\ No newline at end of file +from . import kartu_stock +from . import account_lock_date +from . import res_company
\ No newline at end of file diff --git a/fixco_custom/models/account_lock_date.py b/fixco_custom/models/account_lock_date.py new file mode 100644 index 0000000..1a4234a --- /dev/null +++ b/fixco_custom/models/account_lock_date.py @@ -0,0 +1,12 @@ +from odoo import api, fields, models, SUPERUSER_ID, _ +from odoo.exceptions import UserError + + +class AccountUpdateLockDate(models.TransientModel): + _inherit = 'account.lock.date' + + excluded_user_ids = fields.Many2many( + related='company_id.excluded_user_ids', + readonly=False, + string="Excluded Users" + )
\ No newline at end of file diff --git a/fixco_custom/models/account_move.py b/fixco_custom/models/account_move.py index d727380..376c368 100644 --- a/fixco_custom/models/account_move.py +++ b/fixco_custom/models/account_move.py @@ -62,6 +62,21 @@ class AccountMove(models.Model): ) soo_number = fields.Char('SOO Number') + # def _check_lock_date(self): + # _logger.warning("CHECK LOCK DATE TRIGGERED BY %s", self.env.user.name) + + # moves_to_check = self.filtered( + # lambda m: self.env.user not in m.company_id.excluded_user_ids + # ) + + # _logger.warning("MOVES TO CHECK: %s", moves_to_check) + + # if moves_to_check: + # return super(AccountMove, moves_to_check)._check_lock_date() + + # _logger.warning("LOCK BYPASSED") + # return True + @api.depends('line_ids.partner_id') def _compute_partner_compute(self): for move in self: diff --git a/fixco_custom/models/res_company.py b/fixco_custom/models/res_company.py new file mode 100644 index 0000000..ed36141 --- /dev/null +++ b/fixco_custom/models/res_company.py @@ -0,0 +1,17 @@ +from odoo import models, fields +from datetime import date + +class ResCompany(models.Model): + _inherit = 'res.company' + + excluded_user_ids = fields.Many2many( + 'res.users', + string="Excluded Users" + ) + def _get_user_fiscal_lock_date(self): + self.ensure_one() + + if self.env.user in self.excluded_user_ids: + return date.min + + return super()._get_user_fiscal_lock_date()
\ No newline at end of file diff --git a/fixco_custom/views/account_lock_date.xml b/fixco_custom/views/account_lock_date.xml new file mode 100644 index 0000000..46705cb --- /dev/null +++ b/fixco_custom/views/account_lock_date.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<odoo> + <data> + <record id="account_lock_date_inherit_wizard" model="ir.ui.view"> + <field name="name">account.lock.date.inherit.wizard</field> + <field name="model">account.lock.date</field> + <field name="inherit_id" ref="base_accounting_kit.account_update_lock_date_form_view"/> + <field name="arch" type="xml"> + <field name="fiscalyear_lock_date" position="after"> + <field name="excluded_user_ids"/> + </field> + </field> + </record> + </data> +</odoo> |
