diff --git a/modules/purchase_trade/purchase.py b/modules/purchase_trade/purchase.py index d50f369..63d8314 100755 --- a/modules/purchase_trade/purchase.py +++ b/modules/purchase_trade/purchase.py @@ -284,9 +284,25 @@ class Purchase(metaclass=PoolMeta): depends=['bank_accounts']) our_bank_account = fields.Many2One( 'bank.account', "Our Bank Account") - from_location = fields.Many2One('stock.location', 'From location', required=True,domain=[('type', "!=", 'customer')]) - to_location = fields.Many2One('stock.location', 'To location', required=True,domain=[('type', "!=", 'supplier')]) - shipment_in = fields.Many2One('stock.shipment.in','Purchases') + from_location = fields.Many2One('stock.location', 'From location', required=True,domain=[('type', "!=", 'customer')]) + to_location = fields.Many2One('stock.location', 'To location', required=True,domain=[('type', "!=", 'supplier')]) + first_line_product = fields.Function( + fields.Many2One('product.product', "Product"), + 'get_first_line_product') + first_line_price_type = fields.Function(fields.Selection([ + ('cash', 'Cash Price'), + ('priced', 'Priced'), + ('basis', 'Basis'), + ('efp', 'EFP'), + ], "Price Type"), 'get_first_line_price_type') + first_line_del_period = fields.Function( + fields.Many2One('product.month', "Delivery Period"), + 'get_first_line_del_period') + first_line_from_del = fields.Function( + fields.Date("Delivery From"), 'get_first_line_from_del') + first_line_to_del = fields.Function( + fields.Date("Delivery To"), 'get_first_line_to_del') + shipment_in = fields.Many2One('stock.shipment.in','Purchases') broker = fields.Many2One('party.party',"Broker",domain=[('categories.parent', 'child_of', [4])]) tol_min = fields.Numeric("Tol - in %", required=True) tol_max = fields.Numeric("Tol + in %", required=True) @@ -499,6 +515,35 @@ class Purchase(metaclass=PoolMeta): return True return False + def _get_first_trade_line(self): + for line in self.lines or []: + if getattr(line, 'type', None) == 'line': + return line + + @staticmethod + def _record_id(record): + return getattr(record, 'id', record) if record else None + + def get_first_line_product(self, name): + line = self._get_first_trade_line() + return self._record_id(getattr(line, 'product', None)) + + def get_first_line_price_type(self, name): + line = self._get_first_trade_line() + return getattr(line, 'price_type', None) if line else None + + def get_first_line_del_period(self, name): + line = self._get_first_trade_line() + return self._record_id(getattr(line, 'del_period', None)) + + def get_first_line_from_del(self, name): + line = self._get_first_trade_line() + return getattr(line, 'from_del', None) if line else None + + def get_first_line_to_del(self, name): + line = self._get_first_trade_line() + return getattr(line, 'to_del', None) if line else None + @classmethod def delete(cls, purchases): for purchase in purchases: diff --git a/modules/purchase_trade/tests/test_module.py b/modules/purchase_trade/tests/test_module.py index 20b7fa3..e90c1b6 100644 --- a/modules/purchase_trade/tests/test_module.py +++ b/modules/purchase_trade/tests/test_module.py @@ -24,6 +24,35 @@ class PurchaseTradeTestCase(ModuleTestCase): 'Test purchase_trade module' module = 'purchase_trade' + @with_transaction() + def test_purchase_list_fields_use_first_trade_line(self): + 'purchase list helper fields use the first real purchase line' + Purchase = Pool().get('purchase.purchase') + + product = Mock(id=10) + period = Mock(id=20) + comment_line = Mock(type='comment') + trade_line = Mock( + type='line', + product=product, + price_type='basis', + del_period=period, + from_del=datetime.date(2026, 7, 1), + to_del=datetime.date(2026, 7, 31), + ) + purchase = Purchase() + purchase.lines = [comment_line, trade_line] + + self.assertEqual(purchase.get_first_line_product(None), 10) + self.assertEqual(purchase.get_first_line_price_type(None), 'basis') + self.assertEqual(purchase.get_first_line_del_period(None), 20) + self.assertEqual( + purchase.get_first_line_from_del(None), + datetime.date(2026, 7, 1)) + self.assertEqual( + purchase.get_first_line_to_del(None), + datetime.date(2026, 7, 31)) + @with_transaction() def test_get_totals_without_rows(self): 'get_totals returns zeros when the query has no row' diff --git a/modules/purchase_trade/view/purchase_tree.xml b/modules/purchase_trade/view/purchase_tree.xml index aca9a0b..691d700 100755 --- a/modules/purchase_trade/view/purchase_tree.xml +++ b/modules/purchase_trade/view/purchase_tree.xml @@ -4,5 +4,17 @@ this repository contains the full copyright notices and license terms. --> + + + + + + + - \ No newline at end of file + diff --git a/notes/accounting/excel_api/GLAccountsExcelApi.bas b/notes/accounting/excel_api/GLAccountsExcelApi.bas index 019c6a5..f835206 100644 --- a/notes/accounting/excel_api/GLAccountsExcelApi.bas +++ b/notes/accounting/excel_api/GLAccountsExcelApi.bas @@ -15,13 +15,7 @@ Option Explicit ' dans n'importe quelle cellule, puis F9 pour recalculer. ' Mode macro : remplis Setup!B6:B9, lance RefreshGLApi. -Private Const GL_API_CONNECTION_STRING As String = _ - "Driver={PostgreSQL Unicode(x64)};" & _ - "Server=vps107.geneva.hosting;" & _ - "Port=5432;" & _ - "Database=tradon;" & _ - "Uid=postgres;" & _ - "Pwd=dsproject;" +Private Const GL_API_CONNECTION_STRING As String = "DSN=tradon;" Private gConnection As Object Private gCache As Object diff --git a/notes/accounting/excel_api/GL_Accounts_Client_Template.xlsm b/notes/accounting/excel_api/GL_Accounts_Client_Template.xlsm index 3a82814..878e148 100644 Binary files a/notes/accounting/excel_api/GL_Accounts_Client_Template.xlsm and b/notes/accounting/excel_api/GL_Accounts_Client_Template.xlsm differ