minor fixes
This commit is contained in:
parent
a489572ba1
commit
3e02775251
|
@ -127,7 +127,7 @@ class MainWindow(FrontWindow):
|
|||
self.store.create_table_config()
|
||||
self._local_config = self.store.get_config()
|
||||
if not self._local_config:
|
||||
company_id = self.device['shop.company']
|
||||
company_id = self.device['shop']['company']['id']
|
||||
self._local_config = self.store.set_config([company_id])
|
||||
|
||||
def set_cache_products(self):
|
||||
|
@ -348,9 +348,8 @@ class MainWindow(FrontWindow):
|
|||
])
|
||||
|
||||
self.shop = self.device['shop']
|
||||
self.company = self.shop['company']
|
||||
|
||||
self.shop_taxes = self.shop['taxes']
|
||||
self.company = self.shop['company']
|
||||
self._journals = dict([(j['id'], j) for j in self.device['journals']])
|
||||
|
||||
self.employees = self.Employee.find([
|
||||
|
@ -385,7 +384,7 @@ class MainWindow(FrontWindow):
|
|||
if self._config['show_stock_pos'] in ('value', 'icon'):
|
||||
self.stock_context = {
|
||||
'stock_date_end': date.today(),
|
||||
'locations': [self.shop['warehouse']],
|
||||
'locations': [self.shop['warehouse']['id']],
|
||||
}
|
||||
return True
|
||||
|
||||
|
@ -809,8 +808,7 @@ class MainWindow(FrontWindow):
|
|||
sale_line, = self.ModSaleLine.find([
|
||||
('id', '=', self._current_line_id)
|
||||
])
|
||||
|
||||
price_w_tax = sale_line['product.template.sale_price_w_tax']
|
||||
price_w_tax = sale_line['unit_price_w_tax']
|
||||
if price_w_tax <= Decimal(value):
|
||||
# Change unit price
|
||||
discount_valid = self.set_unit_price(value)
|
||||
|
@ -1064,7 +1062,7 @@ class MainWindow(FrontWindow):
|
|||
|
||||
def validate_payment_term(self):
|
||||
is_credit = self._payment_terms[str(self.field_payment_term_id)]['is_credit']
|
||||
party = self.Party.find([('id', '=', self.party_id)])[0]
|
||||
party, = self.Party.find([('id', '=', self.party_id)])
|
||||
if is_credit:
|
||||
if self.party_id == self.default_party['id']:
|
||||
self.dialog('customer_not_credit')
|
||||
|
@ -1372,6 +1370,9 @@ class MainWindow(FrontWindow):
|
|||
]
|
||||
|
||||
sales = self.ModSale.find(dom, order=[('id', 'DESC')])
|
||||
# for sale in sales:
|
||||
# if sale['salesman']:
|
||||
# print(sale['salesman'])
|
||||
self.dialog_search_sales.set_from_values(sales)
|
||||
|
||||
if self.enviroment == 'retail':
|
||||
|
@ -1451,8 +1452,8 @@ class MainWindow(FrontWindow):
|
|||
self.field_payment_term_id = sale['payment_term']
|
||||
self.field_payment_term.setText(sale['payment_term.name'] or '')
|
||||
if sale.get('salesman'):
|
||||
self.field_salesman.setText(sale['salesman.rec_name'] or '')
|
||||
self.field_salesman_id = sale['salesman']
|
||||
self.field_salesman.setText(sale['salesman']['name'] or '')
|
||||
self.field_salesman_id = sale['salesman']['id']
|
||||
|
||||
res = self.ModSale.get_invoice_type({'sale_id': sale_id})
|
||||
if res:
|
||||
|
@ -1471,18 +1472,18 @@ class MainWindow(FrontWindow):
|
|||
|
||||
self.field_change.zero()
|
||||
if self._commission_activated:
|
||||
if hasattr(self, 'field_agent') and sale.get('agent.party.name') \
|
||||
if hasattr(self, 'field_agent') and sale.get('agent') \
|
||||
and sale.get('commission'):
|
||||
commission = sale.get('commission')
|
||||
self.field_agent.setText('[' + str(int(commission)) + ']' + ' ' + sale.get('agent.party.name'))
|
||||
self.field_agent_id = sale.get('agent')
|
||||
self.field_agent_ask.setText(sale.get('agent.party.name'))
|
||||
self.field_agent.setText('[' + str(int(commission)) + ']' + ' ' + sale['agent']['name'])
|
||||
self.field_agent_id = sale['agent']['id']
|
||||
self.field_agent_ask.setText(sale['agent']['name'])
|
||||
self.field_commission_ask.setText(str(commission))
|
||||
self._set_commission_amount(sale['untaxed_amount'], commission)
|
||||
|
||||
self.line_ids = [l['id'] for l in sale.get('lines')]
|
||||
if sale.get('lines'):
|
||||
lines = self.ModSaleLine.find([
|
||||
('id', 'in', sale.get('lines'))
|
||||
('id', 'in', self.line_ids),
|
||||
])
|
||||
sale['lines'] = lines
|
||||
for line in lines:
|
||||
|
@ -1493,8 +1494,8 @@ class MainWindow(FrontWindow):
|
|||
self.table_payment_lines.record_add(payment)
|
||||
|
||||
self.set_state('add')
|
||||
self.party_id = sale['party']
|
||||
self.field_party.setText(sale['party.name'])
|
||||
self.party_id = sale['party']['id']
|
||||
self.field_party.setText(sale['party']['name'])
|
||||
self.set_amounts(sale)
|
||||
self.set_amount_received()
|
||||
self.field_amount.zero()
|
||||
|
@ -1646,8 +1647,8 @@ class MainWindow(FrontWindow):
|
|||
headers['number'] = {'desc': self.tr('NUMBER'), 'type': 'char'}
|
||||
headers['invoice_number'] = {'desc': self.tr('INVOICE'), 'type': 'char'}
|
||||
headers['party.name'] = {'desc': self.tr('PARTY'), 'type': 'char'}
|
||||
headers['sale_date'] = {'desc': self.tr('DATE'), 'type': 'date'}
|
||||
headers['salesman.party.name'] = {'desc': self.tr('SALESMAN'), 'type': 'char'}
|
||||
headers['sale_date'] = {'desc': self.tr('DATE'), 'type': 'char'}
|
||||
headers['salesman.name'] = {'desc': self.tr('SALESMAN'), 'type': 'char'}
|
||||
headers['position'] = {'desc': self.tr('POSITION'), 'type': 'char'}
|
||||
headers['total_amount_cache'] = {'desc': self.tr('TOTAL AMOUNT'), 'type': 'number'}
|
||||
|
||||
|
@ -1667,7 +1668,6 @@ class MainWindow(FrontWindow):
|
|||
headers = OrderedDict()
|
||||
headers['id'] = {'desc': self.tr('ID'), 'type': 'char'}
|
||||
headers['code'] = {'desc': self.tr('CODE'), 'type': 'char'}
|
||||
|
||||
if self._config.get('show_stock_pos') in ['icon', 'value']:
|
||||
headers['quantity'] = {'desc': self.tr('STOCK'), 'type': 'number'}
|
||||
if self._config['show_stock_pos'] == 'icon':
|
||||
|
@ -1690,6 +1690,7 @@ class MainWindow(FrontWindow):
|
|||
if not self._config.get('encoded_sale_price'):
|
||||
headers['template.sale_price_w_tax'] = price
|
||||
else:
|
||||
price['type'] = 'char'
|
||||
headers['encoded_sale_price'] = price
|
||||
|
||||
_cols_width.append(100)
|
||||
|
@ -1804,7 +1805,6 @@ class MainWindow(FrontWindow):
|
|||
products = self.store.find_product_elastic(domain, limit=100)
|
||||
else:
|
||||
products = self.Product.find(domain, limit=100, ctx=self.stock_context)
|
||||
|
||||
self.dialog_search_products.set_from_values(products)
|
||||
|
||||
def on_search_party(self):
|
||||
|
@ -2093,6 +2093,12 @@ class MainWindow(FrontWindow):
|
|||
return True
|
||||
|
||||
def add_sale_line(self, record):
|
||||
if not record.get('unit.symbol'):
|
||||
record['unit.symbol'] = record['unit']['symbol']
|
||||
if not record.get('product.template.name'):
|
||||
record['product.template.name'] = record['product']['template']['name']
|
||||
if not record.get('product.code'):
|
||||
record['product.code'] = record['product']['code']
|
||||
rec = self.model_sale_lines.add_record(record)
|
||||
self.field_amount.setText(rec['amount_w_tax'])
|
||||
|
||||
|
@ -2239,8 +2245,12 @@ class MainWindow(FrontWindow):
|
|||
})
|
||||
|
||||
if _record:
|
||||
_record['product.template.name'] = _record['product']['name']
|
||||
_record['product.code'] = _record['product']['code']
|
||||
if not _record.get('unit.symbol'):
|
||||
_record['unit.symbol'] = _record['unit']['symbol']
|
||||
if not _record.get('product.template.name'):
|
||||
_record['product.template.name'] = _record['product']['template']['name']
|
||||
if not _record.get('product.code'):
|
||||
_record['product.code'] = _record['product']['code']
|
||||
self.model_sale_lines.update_record(_record)
|
||||
|
||||
self.update_total_amount()
|
||||
|
|
Loading…
Reference in New Issue