[MOV] account: Move account part from warning module

This commit is contained in:
Yannick Tivisse
2016-04-07 10:08:19 +02:00
parent 5a52c1bcfb
commit df38cf9502
5 changed files with 39 additions and 2 deletions
+17
View File
@@ -464,6 +464,22 @@ class AccountInvoice(models.Model):
payment_term_id = p.property_supplier_payment_term_id.id
fiscal_position = p.property_account_position_id.id
bank_id = p.bank_ids and p.bank_ids.ids[0] or False
# If partner has no warning, check its company
if p.invoice_warn == 'no-message' and p.parent_id:
p = p.parent_id
if p.invoice_warn != 'no-message':
# Block if partner only has warning but parent company is blocked
if p.invoice_warn != 'block' and p.parent_id and p.parent_id.invoice_warn == 'block':
p = p.parent_id
warning = {
'title': _("Warning for %s") % p.name,
'message': p.invoice_warn_msg
}
if p.invoice_warn == 'block':
self.partner_id = False
return {'warning': warning}
self.account_id = account_id
self.payment_term_id = payment_term_id
self.fiscal_position_id = fiscal_position
@@ -471,6 +487,7 @@ class AccountInvoice(models.Model):
if type in ('in_invoice', 'in_refund'):
self.partner_bank_id = bank_id
@api.onchange('journal_id')
def _onchange_journal_id(self):
if self.journal_id:
+3 -1
View File
@@ -6,7 +6,7 @@ import time
from openerp import api, fields, models, _
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
from openerp.exceptions import ValidationError
from openerp.addons.base.res.res_partner import WARNING_MESSAGE, WARNING_HELP
class AccountFiscalPosition(models.Model):
_name = 'account.fiscal.position'
@@ -445,6 +445,8 @@ class ResPartner(models.Model):
contract_ids = fields.One2many('account.analytic.account', 'partner_id', string='Contracts', readonly=True)
bank_account_count = fields.Integer(compute='_compute_bank_count', string="Bank")
trust = fields.Selection([('good', 'Good Debtor'), ('normal', 'Normal Debtor'), ('bad', 'Bad Debtor')], string='Degree of trust you have in this debtor', default='normal', company_dependent=True)
invoice_warn = fields.Selection(WARNING_MESSAGE, 'Invoice', help=WARNING_HELP, required=True, default="no-message")
invoice_warn_msg = fields.Text('Message for Invoice')
@api.multi
def _compute_bank_count(self):
+8
View File
@@ -119,6 +119,14 @@
</group>
</group>
<page name="warnings" position="inside">
<group colspan="2" col="2">
<separator string="Warning on the Invoice" colspan="4"/>
<field name="invoice_warn" nolabel="1" />
<field name="invoice_warn_msg" colspan="3" nolabel="1"
attrs="{'required':[('invoice_warn','!=','no-message')],'readonly':[('invoice_warn','=','no-message')]}"/>
</group>
</page>
</field>
</record>
+10 -1
View File
@@ -15,6 +15,16 @@ from odoo.modules import get_module_resource
from odoo.osv.expression import get_unaccent_wrapper
from odoo.exceptions import UserError, ValidationError
# Global variables used for the warning fields declared on the res.partner
# in the following modules : sale, purchase, account, stock
WARNING_MESSAGE = [
('no-message','No Message'),
('warning','Warning'),
('block','Blocking Message')
]
WARNING_HELP = _('Selecting the "Warning" option will notify user with the message, Selecting "Blocking Message" will throw an exception with the message and block the flow. The Message has to be written in the next field.')
ADDRESS_FORMAT_CLASSES = {
'%(city)s %(state_code)s\n%(zip)s': 'o_city_state',
'%(zip)s %(city)s': 'o_zip_city'
@@ -112,7 +122,6 @@ class PartnerTitle(models.Model):
name = fields.Char(string='Title', required=True, translate=True)
shortcut = fields.Char(string='Abbreviation', translate=True)
class Partner(models.Model, FormatAddress):
_description = 'Partner'
_name = "res.partner"
@@ -320,6 +320,7 @@
</group>
</group>
</page>
<page string="Warnings" name="warnings"/>
</notebook>
</sheet>
</form>