[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() date = self.get_date_context()
#dd = date.day
#mm = date.month
#yyyy = date.year
#yy = yyyy % 100
#MM = months[mm]
# ctx keys must be declared in this xml # ctx keys must be declared in this xml
ctx = { ctx = {
"contract_number": self.name, "contract_number": self.name,
# "dd": dd, "dd": date.get('dd'),
# "mm": mm, "mm": date.get('mm'),
# "MM": MM, "MM": date.get('MM'),
# "yy": yy, "yy": date.get('yy'),
# "yyyy": yyyy, "yyyy": date.get('yyyy'),
"seller_name": seller.name, "seller_name": seller.name,
"seller_company_form": seller.company_form, "seller_company_form": seller.company_form,

View File

@ -97,8 +97,20 @@ class PartnerContract(models.Model):
"context": {"self_id": self.id}, "context": {"self_id": self.id},
} }
def get_date(self): def get_date_context(self):
return self.date_conclusion_fix or self.date_conclusion_fix or self.create_date 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): class PrintTemplate(models.Model):