Compare commits
2 Commits
14.0-add-p
...
14.0-expli
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c12b496004 | ||
|
|
447b0107be |
@@ -2,10 +2,12 @@
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.tools import float_is_zero
|
||||
from odoo.tools.misc import format_date
|
||||
from odoo.osv import expression
|
||||
from datetime import timedelta
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class AccountMove(models.Model):
|
||||
@@ -207,6 +209,18 @@ class AccountMove(models.Model):
|
||||
self.ensure_one()
|
||||
return '%s.pdf' % (self.name and self.name.replace('/', '_') or 'INV')
|
||||
|
||||
def _get_accounting_date(self, invoice_date, has_tax):
|
||||
# On vendor bills/refunds, we want date = invoice_date unless
|
||||
# we have a company tax_lock_date and the invoice has taxes
|
||||
# and invoice_date <= tax_lock_date
|
||||
date = super()._get_accounting_date(invoice_date, has_tax)
|
||||
if self.is_purchase_document(include_receipts=True):
|
||||
tax_lock_date = self.company_id.tax_lock_date
|
||||
if invoice_date and tax_lock_date and has_tax and invoice_date <= tax_lock_date:
|
||||
invoice_date = tax_lock_date + timedelta(days=1)
|
||||
date = invoice_date
|
||||
return date
|
||||
|
||||
|
||||
class AccountMoveLine(models.Model):
|
||||
_inherit = 'account.move.line'
|
||||
@@ -263,3 +277,14 @@ class AccountMoveLine(models.Model):
|
||||
if no_product_code_param and no_product_code_param == 'True':
|
||||
self = self.with_context(display_default_code=False)
|
||||
return super()._get_computed_name()
|
||||
|
||||
def reconcile(self):
|
||||
"""Explicit error message if unposted lines"""
|
||||
unposted_ids = self.filtered(lambda l: l.move_id.state != "posted")
|
||||
if unposted_ids:
|
||||
m = _("Please post the following entries before reconciliation :")
|
||||
sep = "\n - "
|
||||
unpost = sep.join([am.display_name for am in unposted_ids.move_id])
|
||||
raise UserError(m + sep + unpost)
|
||||
|
||||
return super().reconcile()
|
||||
|
||||
@@ -33,7 +33,6 @@ This module has been written by Alexis de Lattre from Akretion <alexis.delattre@
|
||||
'views/product_template_view.xml',
|
||||
'views/product_product.xml',
|
||||
'views/product_category_view.xml',
|
||||
'views/product_attribute_view.xml',
|
||||
],
|
||||
'installable': True,
|
||||
}
|
||||
|
||||
@@ -3,4 +3,3 @@ from . import product_template
|
||||
from . import product_supplierinfo
|
||||
from . import product_pricelist
|
||||
from . import product_category
|
||||
from . import product_attribute
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
# Copyright (C) 2022 Akretion (<http://www.akretion.com>).
|
||||
# @author Kévin Roche <kevin.roche@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
class ProductAttribute(models.Model):
|
||||
_inherit = "product.attribute"
|
||||
|
||||
values_count = fields.Integer(compute="_compute_values_count")
|
||||
|
||||
@api.depends("value_ids")
|
||||
def _compute_values_count(self):
|
||||
for attr in self:
|
||||
attr.values_count = len(attr.value_ids)
|
||||
|
||||
def show_values_ids(self):
|
||||
return {
|
||||
"name": "Attributes Lines",
|
||||
"type": "ir.actions.act_window",
|
||||
"res_id": self.id,
|
||||
"view_mode": "tree",
|
||||
"res_model": "product.attribute.value",
|
||||
"view_id":self.env.ref("product_usability.product_attribute_value_view_tree").id,
|
||||
"target": "current",
|
||||
"domain": [("id", "in", self.value_ids.ids)],
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="product_attribute_values_button" model="ir.ui.view">
|
||||
<field name="model">product.attribute</field>
|
||||
<field name="inherit_id" ref="product.product_attribute_view_form" />
|
||||
<field name="arch" type="xml">
|
||||
<group name="main_fields" position='before'>
|
||||
<div class="oe_button_box" name="button_box">
|
||||
<button
|
||||
name="show_values_ids"
|
||||
type="object"
|
||||
class="oe_stat_button"
|
||||
icon="fa-tasks"
|
||||
>
|
||||
<field
|
||||
name="values_count"
|
||||
widget="statinfo"
|
||||
string="Attribute Values"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="product_attribute_value_view_tree">
|
||||
<field name="name">product.attribute.value.view.tree</field>
|
||||
<field name="model">product.attribute.value</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Attributes Values">
|
||||
<field name="name"/>
|
||||
<field name="is_custom"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user