merge
This commit is contained in:
commit
1f3b1d003f
20
invoice.py
20
invoice.py
|
@ -25,6 +25,8 @@ class Invoice:
|
|||
cls._error_messages.update({
|
||||
'milestone_amount': ('Amount of invoice "%s" must be '
|
||||
'equal than its milestone "%s" amount'),
|
||||
'reset_invoice_milestone': ('You cannot reset to draft '
|
||||
'an invoice generated by a milestone.'),
|
||||
})
|
||||
|
||||
@classmethod
|
||||
|
@ -34,7 +36,6 @@ class Invoice:
|
|||
record.check_milestone_amount()
|
||||
|
||||
def check_milestone_amount(self):
|
||||
|
||||
if not self.milestone:
|
||||
return
|
||||
if (self.milestone.invoice_method == 'amount' and
|
||||
|
@ -52,6 +53,23 @@ class Invoice:
|
|||
def search_milestone_group(cls, name, clause):
|
||||
return [('milestone.group',) + tuple(clause[1:])]
|
||||
|
||||
@classmethod
|
||||
def draft(cls, invoices):
|
||||
pool = Pool()
|
||||
Milestone = pool.get('account.invoice.milestone')
|
||||
|
||||
milestone_to_proceed = []
|
||||
for invoice in invoices:
|
||||
if invoice.state == 'cancel' and invoice.milestone:
|
||||
cls.raise_user_error('reset_invoice_milestone')
|
||||
elif invoice.state == 'posted' and invoice.milestone:
|
||||
milestone_to_proceed.append(invoice.milestone)
|
||||
|
||||
res = super(Invoice, cls).draft(invoices)
|
||||
if milestone_to_proceed:
|
||||
Milestone.proceed(milestone_to_proceed)
|
||||
return res
|
||||
|
||||
@classmethod
|
||||
def post(cls, invoices):
|
||||
pool = Pool()
|
||||
|
|
|
@ -86,6 +86,10 @@ msgctxt "error:account.invoice:"
|
|||
msgid "Amount of invoice \"%s\" must be equal than its milestone \"%s\" amount"
|
||||
msgstr "L'import de la factura \"%s\" ha de ser igual que el de la seva fita \"%s\""
|
||||
|
||||
msgctxt "error:account.invoice:"
|
||||
msgid "You cannot reset to draft an invoice generated by a milestone."
|
||||
msgstr "No podeu restaurar a esborrany una factura generada per una fita."
|
||||
|
||||
msgctxt "field:account.configuration,milestone_advancement_product:"
|
||||
msgid "Milestone Advancement Product"
|
||||
msgstr "Producte dels avançaments de fites"
|
||||
|
@ -862,9 +866,10 @@ msgctxt "selection:account.invoice.milestone,kind:"
|
|||
msgid "System"
|
||||
msgstr "Sistema"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "selection:account.invoice.milestone,month:"
|
||||
msgid ""
|
||||
msgstr ""
|
||||
msgstr " "
|
||||
|
||||
msgctxt "selection:account.invoice.milestone,month:"
|
||||
msgid "April"
|
||||
|
@ -938,9 +943,10 @@ msgctxt "selection:account.invoice.milestone,state:"
|
|||
msgid "Succeeded"
|
||||
msgstr "Amb èxit"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "selection:account.invoice.milestone,trigger:"
|
||||
msgid ""
|
||||
msgstr ""
|
||||
msgstr " "
|
||||
|
||||
msgctxt "selection:account.invoice.milestone,trigger:"
|
||||
msgid "On % sent"
|
||||
|
@ -954,9 +960,10 @@ msgctxt "selection:account.invoice.milestone,trigger:"
|
|||
msgid "On Order Fully Sent"
|
||||
msgstr "Al enviar completament la venda"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "selection:account.invoice.milestone,weekday:"
|
||||
msgid ""
|
||||
msgstr ""
|
||||
msgstr " "
|
||||
|
||||
msgctxt "selection:account.invoice.milestone,weekday:"
|
||||
msgid "Friday"
|
||||
|
@ -1030,9 +1037,10 @@ msgctxt "selection:account.invoice.milestone.type,kind:"
|
|||
msgid "System"
|
||||
msgstr "Sistema"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "selection:account.invoice.milestone.type,month:"
|
||||
msgid ""
|
||||
msgstr ""
|
||||
msgstr " "
|
||||
|
||||
msgctxt "selection:account.invoice.milestone.type,month:"
|
||||
msgid "April"
|
||||
|
@ -1082,9 +1090,10 @@ msgctxt "selection:account.invoice.milestone.type,month:"
|
|||
msgid "September"
|
||||
msgstr "Setembre"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "selection:account.invoice.milestone.type,trigger:"
|
||||
msgid ""
|
||||
msgstr ""
|
||||
msgstr " "
|
||||
|
||||
msgctxt "selection:account.invoice.milestone.type,trigger:"
|
||||
msgid "On % sent"
|
||||
|
@ -1098,9 +1107,10 @@ msgctxt "selection:account.invoice.milestone.type,trigger:"
|
|||
msgid "On Order Fully Sent"
|
||||
msgstr "Al enviar completament la venda"
|
||||
|
||||
#, fuzzy
|
||||
msgctxt "selection:account.invoice.milestone.type,weekday:"
|
||||
msgid ""
|
||||
msgstr ""
|
||||
msgstr " "
|
||||
|
||||
msgctxt "selection:account.invoice.milestone.type,weekday:"
|
||||
msgid "Friday"
|
||||
|
|
|
@ -85,6 +85,10 @@ msgctxt "error:account.invoice:"
|
|||
msgid "Amount of invoice \"%s\" must be equal than its milestone \"%s\" amount"
|
||||
msgstr "El importe de la factura \"%s\" debe ser igual que el de su hito \"%s\"."
|
||||
|
||||
msgctxt "error:account.invoice:"
|
||||
msgid "You cannot reset to draft an invoice generated by a milestone."
|
||||
msgstr "No puede restaurar a borrador una factura generada por un hito."
|
||||
|
||||
msgctxt "field:account.configuration,milestone_advancement_product:"
|
||||
msgid "Milestone Advancement Product"
|
||||
msgstr "Producto avances de hitos"
|
||||
|
|
12
milestone.py
12
milestone.py
|
@ -37,9 +37,9 @@ def d_round(number, digits):
|
|||
class AccountInvoiceMilestoneGroupType(ModelSQL, ModelView):
|
||||
'Account Invoice Milestone Group Type'
|
||||
__name__ = 'account.invoice.milestone.group.type'
|
||||
name = fields.Char('Name', required=True)
|
||||
name = fields.Char('Name', required=True, translate=True)
|
||||
active = fields.Boolean('Active')
|
||||
description = fields.Char('Description')
|
||||
description = fields.Char('Description', translate=True)
|
||||
lines = fields.One2Many('account.invoice.milestone.type',
|
||||
'milestone_group', 'Lines')
|
||||
|
||||
|
@ -989,6 +989,7 @@ class AccountInvoiceMilestone(Workflow, ModelSQL, ModelView):
|
|||
('processing', 'succeeded'),
|
||||
('processing', 'failed'),
|
||||
('succeeded', 'failed'), # If invoice is cancelled after post
|
||||
('succeeded', 'processing'), # If invoice is draft after post
|
||||
('draft', 'cancel'),
|
||||
('confirmed', 'cancel'),
|
||||
('cancel', 'draft'),
|
||||
|
@ -1210,7 +1211,12 @@ class AccountInvoiceMilestone(Workflow, ModelSQL, ModelView):
|
|||
@classmethod
|
||||
@Workflow.transition('succeeded')
|
||||
def succeed(cls, milestones):
|
||||
pass
|
||||
for milestone in milestones:
|
||||
if (milestone.invoice and milestone.invoice.invoice_date
|
||||
and milestone.invoice.invoice_date
|
||||
!= milestone.invoice_date):
|
||||
milestone.invoice_date = milestone.invoice.invoice_date
|
||||
milestone.save()
|
||||
|
||||
@classmethod
|
||||
@Workflow.transition('failed')
|
||||
|
|
Loading…
Reference in New Issue