Add contact and invoice party
issue8992 review274701003
This commit is contained in:
1 parent
a696dfe3b2
commit
53c570ecff
4 files changed
+43
-9
No files matched your search
@@ -1,3 +1,4 @@
|
||||
* Add contact and invoice party on subscription
|
||||
* Allow invoices to be created in advance
|
||||
|
||||
Version 5.4.0 - 2019-11-04
|
||||
|
||||
@@ -12,6 +12,8 @@ The invoice is generated based on the consumption of each services. Here is the
|
||||
extensive list of the fields:
|
||||
|
||||
- Party: The customer.
|
||||
- Contact: The contact who placed the order.
|
||||
- Invoice Party: An optional different party to invoice.
|
||||
- Invoice Address: The invoice address of the customer.
|
||||
- Number: The internal reference of the subscription.
|
||||
- Reference: The optional external reference of the subscription.
|
||||
|
||||
+30
-7
@@ -60,16 +60,28 @@ class Subscription(Workflow, ModelSQL, ModelView):
|
||||
},
|
||||
depends=['state'],
|
||||
help="The party who subscribes.")
|
||||
contact = fields.Many2One(
|
||||
'party.contact_mechanism', "Contact",
|
||||
search_context={
|
||||
'related_party': Eval('party'),
|
||||
})
|
||||
invoice_party = fields.Many2One('party.party', "Invoice Party",
|
||||
states={
|
||||
'readonly': ((Eval('state') != 'draft')
|
||||
| Eval('lines', [0])),
|
||||
},
|
||||
depends=['state'])
|
||||
invoice_address = fields.Many2One(
|
||||
'party.address', "Invoice Address",
|
||||
domain=[
|
||||
('party', '=', Eval('party')),
|
||||
('party', '=', If(Bool(Eval('invoice_party',)),
|
||||
Eval('invoice_party'), Eval('party'))),
|
||||
],
|
||||
states={
|
||||
'readonly': Eval('state') != 'draft',
|
||||
'required': ~Eval('state').in_(['draft']),
|
||||
},
|
||||
depends=['party', 'state'])
|
||||
depends=['party', 'invoice_party', 'state'])
|
||||
payment_term = fields.Many2One(
|
||||
'account.invoice.payment_term', "Payment Term",
|
||||
states={
|
||||
@@ -196,13 +208,23 @@ class Subscription(Workflow, ModelSQL, ModelView):
|
||||
def default_state(cls):
|
||||
return 'draft'
|
||||
|
||||
@fields.depends('party')
|
||||
@fields.depends('party', 'invoice_party')
|
||||
def on_change_party(self):
|
||||
self.invoice_address = None
|
||||
if not self.invoice_party:
|
||||
self.invoice_address = None
|
||||
if self.party:
|
||||
self.invoice_address = self.party.address_get(type='invoice')
|
||||
if not self.invoice_party:
|
||||
self.invoice_address = self.party.address_get(type='invoice')
|
||||
self.payment_term = self.party.customer_payment_term
|
||||
|
||||
@fields.depends('party', 'invoice_party')
|
||||
def on_change_invoice_party(self):
|
||||
if self.invoice_party:
|
||||
self.invoice_address = self.invoice_party.address_get(
|
||||
type='invoice')
|
||||
elif self.party:
|
||||
self.invoice_address = self.party.address_get(type='invoice')
|
||||
|
||||
@classmethod
|
||||
def set_number(cls, subscriptions):
|
||||
pool = Pool()
|
||||
@@ -362,13 +384,14 @@ class Subscription(Workflow, ModelSQL, ModelView):
|
||||
def _get_invoice(self):
|
||||
pool = Pool()
|
||||
Invoice = pool.get('account.invoice')
|
||||
party = self.invoice_party or self.party
|
||||
invoice = Invoice(
|
||||
company=self.company,
|
||||
type='out',
|
||||
party=self.party,
|
||||
party=party,
|
||||
invoice_address=self.invoice_address,
|
||||
currency=self.currency,
|
||||
account=self.party.account_receivable_used,
|
||||
account=party.account_receivable_used,
|
||||
)
|
||||
invoice.on_change_type()
|
||||
invoice.payment_term = self.payment_term
|
||||
|
||||
@@ -4,14 +4,22 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<form col="6">
|
||||
<label name="party"/>
|
||||
<field name="party"/>
|
||||
<label name="invoice_address"/>
|
||||
<field name="invoice_address"/>
|
||||
<label name="contact"/>
|
||||
<field name="contact"/>
|
||||
<label name="number"/>
|
||||
<field name="number"/>
|
||||
|
||||
<label name="invoice_party"/>
|
||||
<field name="invoice_party"/>
|
||||
<label name="invoice_address"/>
|
||||
<field name="invoice_address"/>
|
||||
<newline/>
|
||||
|
||||
<label name="description"/>
|
||||
<field name="description" colspan="3"/>
|
||||
<label name="reference"/>
|
||||
<field name="reference"/>
|
||||
|
||||
<notebook colspan="6">
|
||||
<page string="Subscription" id="subscription">
|
||||
<label name="start_date"/>
|
||||
|
||||
Reference in new issue
Block a user