[FIX] date error

This commit is contained in:
Stepan Savelyev 2019-12-27 18:52:58 +05:00
parent 0c327980b3
commit 1771cba477
2 changed files with 20 additions and 13 deletions

View File

@ -22,22 +22,17 @@ months = ["",
"мая", "июня", "июля", "августа",
"сентября", "октября", "ноября", "декабря",
]
#date = self.get_date()
#dd = date.day
#mm = date.month
#yyyy = date.year
#yy = yyyy % 100
#MM = months[mm]
date = self.get_date_context()
# ctx keys must be declared in this xml
ctx = {
"contract_number": self.name,
# "dd": dd,
# "mm": mm,
# "MM": MM,
# "yy": yy,
# "yyyy": yyyy,
"dd": date.get('dd'),
"mm": date.get('mm'),
"MM": date.get('MM'),
"yy": date.get('yy'),
"yyyy": date.get('yyyy'),
"seller_name": seller.name,
"seller_company_form": seller.company_form,

View File

@ -97,8 +97,20 @@ class PartnerContract(models.Model):
"context": {"self_id": self.id},
}
def get_date(self):
return self.date_conclusion_fix or self.date_conclusion_fix or self.create_date
def get_date_context(self):
months = ["",
"января", "февраля", "марта", "апреля",
"мая", "июня", "июля", "августа",
"сентября", "октября", "ноября", "декабря",
]
date = self.date_conclusion_fix or self.date_conclusion_fix or self.create_date
return {
"dd": date.day,
"mm": date.month,
"yyyy": date.year,
"yy": date.year % 100,
"MM": months[date.month],
}
class PrintTemplate(models.Model):