diff --git a/__init__.py b/__init__.py index 034f98a..64f8c4d 100644 --- a/__init__.py +++ b/__init__.py @@ -25,6 +25,7 @@ def register(): contract.Contract, contract.ContractMaintenanceServices, contract.ContractEquipment, + contract.CreateContractInitial, party.Address, party.Party, product.Template, @@ -49,6 +50,7 @@ def register(): Pool.register( agended.AssingAgended, agended.ReAssingAgended, + contract.CreateContract, equipment.NewPropietary, maintenance.NewPropietaryMaintenance, module='optical_equipment', type_='wizard') diff --git a/contract.py b/contract.py index 795c1bb..831c866 100644 --- a/contract.py +++ b/contract.py @@ -224,6 +224,13 @@ class CreateContractInitial(ModelView, ModelSQL): @staticmethod def default_company(): return Transaction().context.get('company') + + @staticmethod + def default_currency(): + Company = Pool().get('company.company') + if Transaction().context.get('company'): + company = Company(Transaction().context['company']) + return company.currency.id @classmethod def default_start_date(cls): @@ -238,7 +245,7 @@ class CreateContractInitial(ModelView, ModelSQL): Date = pool.get('ir.date') if self.party: self.invoice_address = self.party.address_get(type='invoice') - if self.party.client_type == "ips": + if self.party.customer_type == "ips": self.end_date = Date.today() + timedelta(days=182) else: self.end_date = Date.today() + timedelta(days=365) @@ -254,7 +261,17 @@ class CreateContract(Wizard): ]) create_contract = StateAction('optical_equipment.act_contract_form') - + + def default_start(self, fields): + if self.record: + default = {'party': self.record.propietary.id, + 'invoice_address': self.record.propietary_address.id, + 'unit_price': (self.record.sale_origin.amount + if self.record.sale_origin.__name__ == "sale.line" + else self.record.sale_origin.total_amount), + } + return default + @property def _subscription_start(self): return dict( diff --git a/locale/es.po b/locale/es.po index 3e89ce4..63d1c3a 100644 --- a/locale/es.po +++ b/locale/es.po @@ -1346,6 +1346,10 @@ msgctxt "field:optical_equipment_create.contract,end_date:" msgid "End Date" msgstr "Fecha Final" +msgctxt "field:optical_equipment_create.contract,unit_price:" +msgid "Unit Price" +msgstr "Precio Unitario" + msgctxt "field:stock.move,equipment:" msgid "Equipment" msgstr "Equipo"