mirror of
https://github.com/bringout/oca-ocb-accounting.git
synced 2026-04-25 20:21:59 +02:00
19.0 vanilla
This commit is contained in:
parent
ba20ce7443
commit
768b70e05e
2357 changed files with 1057103 additions and 712486 deletions
|
|
@ -1,9 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from ast import literal_eval
|
||||
|
||||
from odoo import models, fields
|
||||
from odoo import api, models, fields
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class StockPicking(models.Model):
|
||||
|
|
@ -11,12 +10,25 @@ class StockPicking(models.Model):
|
|||
|
||||
country_code = fields.Char(related="company_id.account_fiscal_country_id.code")
|
||||
|
||||
def action_view_stock_valuation_layers(self):
|
||||
@api.constrains("scheduled_date", "date_done")
|
||||
def _check_backdate_allowed(self):
|
||||
if self.env['ir.config_parameter'].sudo().get_param('stock_account.skip_lock_date_check'):
|
||||
return
|
||||
for picking in self:
|
||||
if picking._is_date_in_lock_period():
|
||||
raise ValidationError(self.env._("You cannot modify the scheduled date of operation %s because it falls within a locked fiscal period.", picking.display_name))
|
||||
|
||||
def _compute_is_date_editable(self):
|
||||
super()._compute_is_date_editable()
|
||||
for picking in self:
|
||||
if picking.is_date_editable and picking.state in ['done', 'cancel'] and picking.ids:
|
||||
picking.is_date_editable = not picking._is_date_in_lock_period()
|
||||
|
||||
def _is_date_in_lock_period(self):
|
||||
self.ensure_one()
|
||||
scraps = self.env['stock.scrap'].search([('picking_id', '=', self.id)])
|
||||
domain = [('id', 'in', (self.move_ids + scraps.move_id).stock_valuation_layer_ids.ids)]
|
||||
action = self.env["ir.actions.actions"]._for_xml_id("stock_account.stock_valuation_layer_action")
|
||||
context = literal_eval(action['context'])
|
||||
context.update(self.env.context)
|
||||
context['no_at_date'] = True
|
||||
return dict(action, domain=domain, context=context)
|
||||
lock = []
|
||||
if self.state == "done":
|
||||
lock += self.company_id._get_lock_date_violations(self.scheduled_date.date(), fiscalyear=True, sale=False, purchase=False, tax=False, hard=True)
|
||||
if self.date_done:
|
||||
lock += self.company_id._get_lock_date_violations(self.date_done.date(), fiscalyear=True, sale=False, purchase=False, tax=False, hard=True)
|
||||
return bool(lock)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue